insert query return id mysql 1

insert query return id mysql

INSERT INTO table_name (col1, col2,...) VALUES ('val1', 'val2'...);

Here is what the above code is Doing:
1. We create a connection to the database.
2. We create a cursor object.
3. We execute the INSERT statement.
4. We execute the SELECT statement to get the last inserted id.
5. We print the last inserted id.
6. We close the cursor object.
7. We close the connection.

Similar Posts