您如何找出MySQL AUTO_INCREMENT最近分配的序列号?
Last_Insert_Id()MySQL函数用于查找AUTO_INCREMENT最近分配的序列号。
示例
mysql> Create table Employee(Id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, Name Varchar(5));
mysql> Insert into Employee(Name) Values('Harvinder');
mysql> Insert into Employee(Name) Values('Suresh');
mysql> Select* from Employee;
+----+---------+
| Id | Name |
+----+---------+
| 1 |Harvinder|
| 2 | Suresh |
+----+---------+
2 rows in set (0.00 sec)
mysql> Select Last_insert_id();
+------------------+
| Last_insert_id() |
+------------------+
| 2 |
+------------------+
1 row in set (0.00 sec)热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短