Answer the question
In order to leave comments, you need to log in
How can an application writing to a MySQL 5.7 database table get back the value of an auto-incrementing primary key?
MySQL 5.7 has a table:
CREATE TABLE user(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
PRIMARY KEY(id)
);
Answer the question
In order to leave comments, you need to log in
Last_insert_id () is said to return the ID of the last inserted record within the current connection. That is, it will always return what you need, even though you have many applications that write to the database
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question