SweatCoder
asked on
last_insert_id
I need to know the last auto_increment value inserted into a given table. in my experiments with last_insert_id, it seems this gives the last id value anywhere in the database, which is useless. is there a way to get the last id value for a specific table?
i can't use max(id) because there are times when the last record was deleted, and i don't want to get the highest id currently in the table, but the highest id that was *ever* in the table.
i can't use max(id) because there are times when the last record was deleted, and i don't want to get the highest id currently in the table, but the highest id that was *ever* in the table.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
leannonn, you came through for me again. that's exactly what i needed.
All you have to do is ask O;)
ASKER
leannonn: I need you over here:
https://www.experts-exchange.com/questions/20890859/date-comparisons.html#10404157
sorry, but this site offers no other way to contact somebody!!!
thanks.
https://www.experts-exchange.com/questions/20890859/date-comparisons.html#10404157
sorry, but this site offers no other way to contact somebody!!!
thanks.
http://www.mysql.com/doc/en/Getting_unique_ID.html
If you want to get the most recently inserted row after you have closed a connection and re-opened it, I can only think you need to have a date_created(TIMESTAMP) column on your table and SELECT MAX(date_created) from it to get this result.