SQL - INSERT and catch the id auto-increment value

前端 未结 7 964
梦毁少年i
梦毁少年i 2020-12-05 19:26

What is the best way to get the auto-id value in the same SQL with a SELECT?

A forum said adding this \"; has Return Scope_Identity()\"
in the end

7条回答
  •  半阙折子戏
    2020-12-05 19:57

    In php: mysql_insert_id() http://us3.php.net/mysql_insert_id

    or

    If you wanted to genterate the number from your mySql select query, you could use this EDIT:

    SELECT LAST_INSERT_ID(`1`) + 1 FROM table 
    

提交回复
热议问题