insert into select 可以加where条件么
3个回答
展开全部
一、INSERT INTO (SELECT FROM)语句(可连表、可加限制条件where子句)
语句形式为:INSERT INTO table2(a,b,d) (SELECT a,b,d FROM table1)
二、如下代码:
INSERT INTO T_COMMISSION
(TYPE_NUM,PRODUCT_NUM,FAST_COMMISSION,CREATE_DATE,EMPLOYEE_ID
,OTHER_FAST_COMMISSION,MONEY,FAST_PRICE,ALL_FAST_COMMISSION
,OTHER_FAST_PRICE,ALL_FAST_PRICE)
(SELECT T1.TYPE_NUM,T2.PRODUCT_NUM,0,SYSDATE,'15145117218',0
,T2.MONEY,T2.MONEY,0,T2.MONEY,T2.MONEY
FROM T_COMMISSION_TYPE T1,T_PRODUCT_TYPE T2 WHERE T1.TYPE_NUM='default_type')
语句形式为:INSERT INTO table2(a,b,d) (SELECT a,b,d FROM table1)
二、如下代码:
INSERT INTO T_COMMISSION
(TYPE_NUM,PRODUCT_NUM,FAST_COMMISSION,CREATE_DATE,EMPLOYEE_ID
,OTHER_FAST_COMMISSION,MONEY,FAST_PRICE,ALL_FAST_COMMISSION
,OTHER_FAST_PRICE,ALL_FAST_PRICE)
(SELECT T1.TYPE_NUM,T2.PRODUCT_NUM,0,SYSDATE,'15145117218',0
,T2.MONEY,T2.MONEY,0,T2.MONEY,T2.MONEY
FROM T_COMMISSION_TYPE T1,T_PRODUCT_TYPE T2 WHERE T1.TYPE_NUM='default_type')
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2015-07-16
展开全部
insert into table (a,b,c)
select * from
( select table1.a,table1.b,table2.c
from table1.a=table2.a(+)--左连接
where table1.a='a')
select * from
( select table1.a,table1.b,table2.c
from table1.a=table2.a(+)--左连接
where table1.a='a')
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询