I have a multiquery statement like the example below where the first query inserts a record.
The second query then adds a relationship to another table using the last_insert_id() function.
The third query I wish to also put the last_insert_id() value from the first query but it's obviously taking the id of the second query.
is there any way to save or reuse the last_insert_id() from the first query? (for use in the 3rd query)
INSERT INTO tbl_contacts (name)
VALUES ("Shaun Perry");
INSERT INTO lnk_contacts (contactId)
INSERT INTO lnk_projects (projectId, contactId)
VALUES (1, LAST_INSERT_ID());