网上对于不同表的merge into的用法很多,可以搜索参考点击
示例代码
根据T_BUSINESS_STATISTICS表的字段station_org_no和字段business_date进行有则更新无则插入
merge into T_BUSINESS_STATISTICS A USING (select '212122222222222' station_org_no,'2021-06-06' business_date from dual ) C
ON(A.station_org_no=C.station_org_no and A.business_date=C.business_date)
when matched then
update SET A.province_org_no='testoo1qqqqxxxxx'
when not matched then
insert(A.id,A.province_org_no,A.station_org_no,A.business_date,CREATED_BY,updated_BY,status) values(212199921,'neworg','212122222222222','2021-06-06',-1,-1,1);
注意:如果有传入或者查询出的连接条件(station_org_no或者business_date)为null,则更新,
A.station_org_no=C.station_org_no and A.business_date=C.business_date