工作中经常会遇到插入一条数据,该数据可能包含固定值,也可能是另一张表中的查询结果
解决该问题分两种情况:
1、当table2存在时:
insert into table1 (x1,x2) values('a',(select x from table2 where x=x))
2、当table2不存在时:
insert into table1(x1,x2) select 'a' , x from table1 where where x=x
转载于:https://www.jianshu.com/p/a9304c4c940d