How find the missing number in a sequence. (mysql)
#1

Hey Guys, I would want know if it's possible with a mysql sentence:

Example:

Код:
ID    |     Name

1           Petra
4           Custodio
How would can find missing number between 1 and 4?

That is to say 2, then 3, and then returns 5?
Reply
#2

Use auto increment.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Use auto increment.
This wont return the free id.
I think this should help you > http://stackoverflow.com/questions/5...e-id-available
Reply
#4

Simply look for the lowest ones that doesn't exist ? doesn't matter if 4 is there, just see if 2 exists, if not return 2;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)