Returning last inserted id from MySql

后端 未结 2 583
庸人自扰
庸人自扰 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:20

    Change the last statement into:

    SELECT CAST(@LASTID AS integer) as last_id_from_accounts;
    

提交回复
热议问题