怎么将select语句的查询结果当作insert语句的values的值

insert into salary(salary_date,emplyid,basesalary,bonussalary)
 values('2016-06-01',select emplyid from emply 
where emplyid not in (select emplyid from salary),1650,300);
 
上面这种是常见的写法,但在MySQL中是会报错的。上面是问题现象。
 
以下是解决方案:如下
insert into salary(emplyid,salary_date,basesalary,bonussalary)
 select(select emplyid from emply where emplyid not in (select emplyid from salary))emplyid,'2016-06-01',1650,300; 

posted @ 2021-01-23 17:06  爱软测_bill  阅读(203)  评论(0)    收藏  举报