i ant to find the next auto increment number
currently with livecode im using SELECT MAX(id) FROM database then adding 1 to it to get the next id that will be used.
however what if i have 6 items, the next to be used will be 7. but if i delete item 6 from the database using my method will give me 6 as the next available one however MySQL will set the next entry as 7
auto increment MySQL
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: auto increment MySQL
Select max(id) after you do the insert? Or perhaps LAST_INSERT_ID()
Re: auto increment MySQL
that works at that point in time. but what if i go do other stuff. Log off the come back then need to find it. I would have to insert something to get the AI number
Re: auto increment MySQL
What about :
It will gives you infos on the table... with "auto increment" = the next value
Code: Select all
SHOW TABLE STATUS WHERE Name = 'yourtable'
Re: auto increment MySQL
thanks. This works
Code: Select all
put "SHOW TABLE STATUS WHERE Name = 'users' " into xSQL
put revDataFromQuery(comma, cr, gConnectionID, xSQL) into maxData
set itemDelimiter to comma
answer item 11 of maxData