表level,其主鍵為lid 1.select max(id) from table 查詢語句:SELECT MAX(lid) FROM LEVEL 返回插入主鍵 2.select LAST_INSERT_ID(id) from table 查詢語句:SELECT LAST_INSERT_ID(li ...
表level,其主鍵為lid
1.select max(id) from table
查詢語句:SELECT MAX(lid) FROM LEVEL
返回插入主鍵
2.select LAST_INSERT_ID(id) from table
查詢語句:SELECT LAST_INSERT_ID(lid) FROM LEVEL;
返回主鍵列表,最後一個值為插入主鍵
3.select @@identity from table
查詢語句:SELECT @@identity FROM level
返回n(表的行數)個主鍵,全為插入主鍵,取其中一個就行