CodePudding user response:
Select @ @ identity; On the back of the insert statement, available from the id of the
mysql> The create table t4 (id int auto_increment, name a varchar (100), the primary key (id));
Query OK, 0 rows affected (0.02 SEC)
mysql>
mysql> Insert into t4 (name) values (" test ");
Query OK, 1 row affected (0.01 SEC)
mysql>
mysql> Select @ @ identity;
+ -- -- -- -- -- -- -- -- -- -- -- -- +
| @ @ identity |
+ -- -- -- -- -- -- -- -- -- -- -- -- +
| | 1
+ -- -- -- -- -- -- -- -- -- -- -- -- +
1 row in the set (0.00 SEC)
mysql> Select * from t4;
+ - + -- -- -- -- -- - +
| | id name |
+ - + -- -- -- -- -- - +
| | 1 test |
+ - + -- -- -- -- -- - +
1 row in the set (0.00 SEC)