MySQL: LAST_INSERT_ID() returns 0

前端 未结 6 1539
天涯浪人
天涯浪人 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:21

    Just my 50 cents for this issue, I simply noticed that you won't get a LAST_INSERT_ID greater than 0 if your table has no AUTO_INCREMENT set to an index.

    I wasted about half hour on this. Turns out I keep getting a LAST_INSERT_ID() of 0, which for this table is actually ok.

提交回复
热议问题