Monday 27 May 2019

MYSQL get last inserted id

INSERT INTO table1 (title,userid) VALUES ('test', 1); 
SET @last_id_in_table1 = LAST_INSERT_ID();
INSERT INTO table2 (parentid,otherid,userid) VALUES (@last_id_in_table1, 4, 1);   


https://stackoverflow.com/questions/3837990/last-insert-id-mysql

No comments:

Post a Comment