|
mysql> select * from t;
+----+------+
| c1 | c2 |
+----+------+
| 1 | abc |
| 2 | qwe |
+----+------+
2 rows in set (0.01 sec)
mysql> select last_insert_id();
+------------------+
| last_insert_id() |
+------------------+
| 2 |
+------------------+
1 row in set (0.00 sec)
mysql> select @@identity;
+------------+
| @@identity |
+------------+
| 2 |
+------------+
1 row in set (0.00 sec)
mysql> insert t(c2) values('fdg'),('fg'),('sd');
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select last_insert_id();
+------------------+
| last_insert_id() |
+------------------+
| 3 |
+------------------+
1 row in set (0.01 sec)
mysql> select @@identity;
+------------+
| @@identity |
+------------+
| 3 | <--- 也有这个问题
+------------+
1 row in set (0.00 sec) |
|