-
Notifications
You must be signed in to change notification settings - Fork 923
Last Inserted ID for MySQL. #1206
Answered
by
aitva
abhishek-hotstar
asked this question in
Q&A
-
CREATE TABLE IF NOT EXISTS student
(
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50) NOT NULL
);
/* name: InsertStudent :exec */
INSERT INTO student (name)
VALUES (?);
The result only returns an error, not the sql.Result
. Only on the result pointer can we call LastInsertId()
. Please suggest a way forward.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions
Answered by
aitva
Sep 21, 2021
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
-
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 (?);
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 2
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