mysql用变量存储插入的id

INSERT into a(value) values ('test');
#set @last_id = LAST_INSERT_ID();
set @last_id = (select max(id) from a);
INSERT INTO b (a_id, `value`) values (@last_id, 'aaaa');
INSERT INTO b (a_id, `value`) values (@last_id, 'tetete');

INSERT into a(value) values ('bbbtest');
set @last_id = (select max(id) from a);
INSERT INTO b (a_id, `value`) values (@last_id, 'aaaa');
INSERT INTO b (a_id, `value`) values (@last_id, 'tetete');

上一篇:Spark Core_资源调度与任务调度详述


下一篇:[bzoj4908][BeiJing2017]开车