您如何找出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 给英雄的祝福语简短