Is there a way to determine the next value of an auto-incremented field in a MySQL database?
Simply checking the highest value of the auto-incremented field at this moment won't work, as the most recently added record could have been deleting again, forming a gap between the currently highest value and the actual next value.
So, is there a way to do this?
MySQL/PHP question
what about:
SELECT id FROM table ORDER BY id DESC LIMIT 1
that will return a single row with only the 'id' of the highest value (and the next auto-incremented value doesn't fill in gaps, but goes from the highest value+1, (unless you've run out of room? unsure))
nevermind, 4days hit the nail most definately on the head there
SELECT id FROM table ORDER BY id DESC LIMIT 1
that will return a single row with only the 'id' of the highest value (and the next auto-incremented value doesn't fill in gaps, but goes from the highest value+1, (unless you've run out of room? unsure))
nevermind, 4days hit the nail most definately on the head there
why do you need to know it anyway? you dont need to hard write it into the DB.
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]