MySQL: LAST_INSERT_ID() returns 0

前端 未结 6 1540
天涯浪人
天涯浪人 2020-11-30 07:28

I\'ve got this test table:

CREATE TABLE IF NOT EXISTS `test` (
    `id` INT(10) AUTO_INCREMENT,
    PRIMARY KEY (`id         


        
6条回答
  •  粉色の甜心
    2020-11-30 08:12

    you have to combine

    INSERT INTO test (title) VALUES ('test');SELECT LAST_INSERT_ID();
    

    Then you will get the last insert id

提交回复
热议问题