MySQL Forums
Forum List  »  General

Re: [newbie] Get ID from previous INSERT?
Posted by: John Doe
Date: February 15, 2023 08:47AM

Done:

=========
CREATE TEMPORARY TABLE dummy (id MEDIUMINT NOT NULL AUTO_INCREMENT,name CHAR(30) NOT NULL,PRIMARY KEY (id));
INSERT INTO dummy (name) VALUES ('blah');
SET @id=LAST_INSERT_ID();
SELECT @id;
INSERT INTO dummy (name) VALUES (@id);
SELECT * FROM dummy;
DROP TABLE dummy;
=========

Options: ReplyQuote


Subject
Written By
Posted
Re: [newbie] Get ID from previous INSERT?
February 15, 2023 08:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.