Click to See Complete Forum and Search --> : How to get AUTO_INCREMENT value?


tim_kinder
06-29-2006, 02:49 AM
Hello,

I want to get AUTO_INCREMENT value from a table; I can do it if there are records in the table (just read the max. id) - but what to do if the table is empty (but AUTO_INCREMENT is greater than 0)?

Sincerely,

Tim Kinder

russell
06-29-2006, 12:31 PM
what db?

tim_kinder
06-29-2006, 08:27 PM
Sorry, I did not mention it - MySQL 3.23

The bigger task is to create an empty table (like original one) and continue to write there with ID's bigger than last one in the original table.

cridley
07-05-2006, 04:22 AM
Why you creating a new table if old one is empty anyway?
One not terribly good solution would be to insert a row, get the id with mysql_insert_id then delete the row and your next id will be that+1 ... Not ideal, there's prob a simple way to get the value your looking for...