Skip to content

Last Inserted ID for MySQL. #1206

Answered by aitva
abhishek-hotstar asked this question in Q&A
Discussion options

You must be logged in to vote

You can get an sql.Result by using the :execresult command:

CREATE TABLE IF NOT EXISTS student
(
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50) NOT NULL
);

/* name: InsertStudent :execresult */
INSERT INTO student (name)
VALUES (?);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by abhishek-hotstar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants