U kunt LAST_INSERT_ID gebruiken () functie.Probeer dit:
INSERT INTO blahblah (test1, test2) VALUES ('test1', 'test2');
SELECT LAST_INSERT_ID() INTO @blahblah;
INSERT INTO blahblah2 (test1, test2) VALUES ('test1', 'test2');
INSERT INTO blahblah3 (test1, test2, lastid) VALUES ('test1', 'test2', @blahblah);