Insert select 和 update select 操作

--将已导入ecc_base_order_his历史表中的ECC_CYCLE_TRANSFER_ACCOUNTS数据有效期未过期预约类数据copy到
--ecc_base_order中
insert into ecc_base_order ebo 
select * from (select his.* from ecc_base_order_his his 
where his.order_no in(select b.order_no from ecc_cycle_transfer_accounts b  left join ecc_base_order a
on a.order_no=b.order_no 
where b.tran_type in('01','02') and  b.plan_status in('00','01') and b.cycle_type <> '00' and a.order_no is null
))
 --将ecc_base_order 和 ecc_cycle_transfer_accounts 中的VALID_STOP_DATE和VALID_TIME一致
update   ecc_base_order   ebo  set   ebo.valid_time = ( select   ecta.valid_stop_date  from 
ecc_cycle_transfer_accounts ecta 
where ecta.order_no = ebo.order_no and ecta.tran_type in('01','02') and  ecta.plan_status in('00','01') and ecta.cycle_type <> '00')
where  ebo.order_no = ( select  ecta.order_no  from  ecc_cycle_transfer_accounts ecta   where  ecta.order_no = ebo.order_no and ecta.tran_type in('01','02') and  ecta.plan_status in('00','01') and ecta.cycle_type <> '00')  
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值