工作中经常会遇到插入一条数据,该数据可能包含固定值,也可能是另一张表中的查询结果
解决该问题分两种情况:
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
工作中经常会遇到插入一条数据,该数据可能包含固定值,也可能是另一张表中的查询结果
解决该问题分两种情况:
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
本文标题:insert,将一个表中的部分数据复制到另一个表中
本文链接:https://www.haomeiwen.com/subject/iqxvtctx.html
网友评论