Jump to content

How To Get The Next Auto-Increment Value In MySQL


JustinK101

Recommended Posts

I see: mysql_insert_id -- Get the ID generated from the previous INSERT operation

But that requires that you have already done an insert operation. I need to just reference the next autoincrement value of the table. Thanks for the help.
Ok so here is what I have:

$sql = "SELECT MAX(ID) AS max_id FROM employees";
$result = mysql_query($sql) or die(fatal_error_alert(mysql_error(), $sql));
$row = mysql_fetch_assoc($result);

Which works, ($row['max_id'] + 1) holds the next autoincrement.

Now, I need to way to manually increment the table employees without doing an insert. I just need to increment the auto-index.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.