How to get last inserted id from table MySQL [duplicate]

If you use php to connect to mysql you can use mysql_insert_id() to point to last inserted id.

Like this :

mysql_query("INSERT INTO mytable (1, 2, 3, 'blah')");
$last_id = mysql_insert_id();

See this : mysql_insert_id()

Leave a Comment