Questions tagged «last-insert-id»

11
LAST_INSERT_ID()MySQL
我有一个MySQL问题,我认为这很容易。运行以下MySql查询时,我需要从table1返回LAST INSERTED ID: INSERT INTO table1 (title,userid) VALUES ('test',1); INSERT INTO table2 (parentid,otherid,userid) VALUES (LAST_INSERT_ID(),4,1); SELECT LAST_INSERT_ID(); 如您所知,当前代码将仅返回table2的LAST INSERT ID而不是table1,即使我插入到table2之间,也如何从table1获取ID?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.