我的数据库有,
mysql> describe students;
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(50) | YES | | NULL | |
+-------+-------------+------+-----+---------+----------------+
我想插入 2 个学生 - 但我想立即知道他们的 ID
mysql> insert into students values (null, 'tom'), (null, 'larry');
如果插入实际上返回了 ID 的结果集,我会喜欢它......又名......
mysql> select id from (insert into students values (null, 'tom'), (null, 'larry'));
嗯?