SELECT LAST_INSERT_ID() Not working with BIGINT on MySQL 5.6.11

前提是你 提交于 2019-12-08 07:17:10

问题


I have a BIGINT field as an auto increment and primary key on a MySQL Innodb table, running MySQL Community Server 5.6.11.

After calling a basic INSERT statement, and then calling SELECT LAST_INSERT_ID(), I'm always returned 0, even though the INSERT statement was sucessful.

Any ideas why this might be happening.

UPDATE: Here is my table definition

CREATE TABLE `Booking` (
  `BookingId` bigint(20) NOT NULL AUTO_INCREMENT,
  `HotelId` int(11) NOT NULL,
  `AgentId` int(11) NOT NULL DEFAULT '0',
  `BookedOn` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `LastChangedBy` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`BookingId`)
 ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=71 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

Here is my INSERT statement

INSERT INTO Booking
(
    HotelId,
    AgentId,        
    BookedOn,
    LastChangedBy
)
VALUES
(
    iHotelId,
    iAgentId,       
    NOW(),
    0
);

SELECT LAST_INSERT_ID() AS BookingId;

来源:https://stackoverflow.com/questions/17491849/select-last-insert-id-not-working-with-bigint-on-mysql-5-6-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!