Using LAST_INSERT_ID() within a multi row insert

后端 未结 2 433
小蘑菇
小蘑菇 2021-01-25 11:39

Is it possible to use LAST_INSERT_ID() within an insert query?

INSERT INTO mytable (col1, col2) VALUES (\'val1\', null), (\'val2\', LAST_INSERT_ID())
         


        
2条回答
  •  野性不改
    2021-01-25 12:19

    From what i found it won't work as LAST_INSERT_ID doesn't have a value until the whole statement has finished.

提交回复
热议问题