Home > database >  Stored procedure how to insert a data returned from the id, bosses, please advice
Stored procedure how to insert a data returned from the id, bosses, please advice

Time:09-16

Call adduser (' fengyu, 0 x6d1cf88c4543d51a1a234745b6014e20)

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)

  • Related