actually, there is, but it involves a right join with an integer table, and setting up the integer table to have as many entries as the maximum ID is painful
also, i cannot think of any reason why you would want to find the "first free" ID, if the ID is some kind of surrogate primary key -- re-using an ID is a very very bad idea
In general, I recommend you use "int unsigned" rather than "int" for IDs. That will give you 4294967295 (232-1)records to insert before you run out of IDs.
And if you are still worried about running out of IDs, then use "bigint unsigned". This will allow you to insert 18446744073709551615 (264-1) records before you run out of IDs. Want the best answers? Ask the best questions:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.