Returning last inserted id from MySql

后端 未结 2 569
庸人自扰
庸人自扰 2021-01-07 01:40

I\'m having a bit of trouble with the following query:

START TRANSACTION;

SET @LASTID = 0;

INSERT INTO `Accounts` (         


        
2条回答
  •  走了就别回头了
    2021-01-07 02:01

    use

     SELECT LAST_INSERT_ID();
    

    http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id

提交回复
热议问题