Is it possible to use LAST_INSERT_ID() within an insert query?
INSERT INTO mytable (col1, col2) VALUES ('val1', null), ('val2', LAST_INSERT_ID())
Trying the above LAST_INSERT_ID() returns 0, Just seeing if i can combine the query.
Is it possible to use LAST_INSERT_ID() within an insert query?
INSERT INTO mytable (col1, col2) VALUES ('val1', null), ('val2', LAST_INSERT_ID())
Trying the above LAST_INSERT_ID() returns 0, Just seeing if i can combine the query.
From what i found it won't work as LAST_INSERT_ID doesn't have a value until the whole statement has finished.