It’s important to note that if you insert multiple records into a table using a single INSERT statement, the LAST_INSERT_ID function will return the last insert id of the first record. Suppose the AUTO_INCREMENT column has the last sequence number 3 and you insert 5 records into the table, when you use the LAST_INSERT_ID function to get the last insert id, you will get 4 instead of 8.
Let’s take a look at the following example: