10- MySQL Last Inserted

0
234

In our previous lesson, we tackle about how to insert a record in a MySQL database table. This time we’re going discuss MySQL Last Inserted to get the last Inserted ID from our table “tblpeople“. Using the AUTO_INCREMENT field, we are able to get the ID of last inserted or updated record immediately.

Since we will be using the same code that we use from our previous topic called “09-MySQL Insert” we only need to add a single line of code for retrieving and echo the Last Inserted ID.

MySQL Last Inserted

Example Using MySQLi(Object-Oriented):

 

Example Using MySQLi(Procedural):

 

Example Using PDO:

 

Our previous Topic Called:09- MySQL Insert Query

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.