SA-MP Forums Archive
How find the missing number in a sequence. (mysql) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How find the missing number in a sequence. (mysql) (/showthread.php?tid=600191)



How find the missing number in a sequence. (mysql) - aoEXE - 05.02.2016

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?


Re: How find the missing number in a sequence. (mysql) - Vince - 05.02.2016

Use auto increment.


Re: How find the missing number in a sequence. (mysql) - GangstaSunny - 05.02.2016

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


Re: How find the missing number in a sequence. (mysql) - PrO.GameR - 05.02.2016

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;