我需要从特定插入的表中获取最后插入的id。假设我有以下代码:
INSERT INTO blahblah (test1, test 2) VALUES ('test1', 'test2');
INSERT INTO blahblah2 (test1, test 2) VALUES ('test1', 'test2');
INSERT INTO blahblah3 (test1, test 2, lastid) VALUES ('test1', 'test2', last id of blahblah);
我如何在表blahblah3中获取表blahblah的插入ID?LAST_INSERT_ID()仅提供上次插入的ID。
问候,Simon :)
INSERT INTO blahblah2
和INSERT INTO blahblah3
行即可解决问题。 - VolkerK