If we insert a row into a mysql table that contains an AUTO_INCREMENT column, we can retrieve the value stored into that column by using the PHP function mysql_insert_id(). so we no need to create separate query to read the newly inserted value.
What is differences between LAST_INSERT_ID() and mysql_insert_id()?
The reason for the differences between LAST_INSERT_ID() and mysql_insert_id() is that LAST_INSERT_ID() is made easy to use in scripts while mysql_insert_id() tries to provide more exact information about what happens to the AUTO_INCREMENT column.
The LAST_INSERT_ID() MYSQL function returns the most recently generated AUTO_INCREMENT value, and is not reset between statements because the value of that function is maintained in the server. Another difference from mysql_insert_id() is that LAST_INSERT_ID() is not updated if you set an AUTO_INCREMENT column to a specific nonspecial value.