Is there a way to insert a row, get the inserted id and use it in the next query all this in just one single query?
INSERT INTO tableA (eID, name, otherStuff) VALUES (NULL, 'emailName', 'otherValues');
SET @tableA_id = SELECT LAST_INSERT_ID();
INSERT INTO tableB (id, emailId, body, name, langId) VALUES (NULL, @tableA_id, 'email text', 'Default', '1');
INSERT INTO tableB (id, emailId, body, name, langId) VALUES (NULL, @tableA_id, 'other language text', 'Default', '2');
In the previous code segment, there are three separate queries and when I execute them in my sql editor it gives me an error here: SET @tableA_id = LAST_INSERT_ID();
Again, there are 3 separate queries here, is there a way to have something like a subquery in order to achieve this?