天天看点

Oracle 多表关联查询后修改

--t_veh_traffic_vio 违法表
--vhcl_info 车辆信息表

--单表修改,修改2014年4月份违法数据的同步标志位
update t_veh_traffic_vio t
   set t.synchflag = 0, t.synchstatus = 'u'
 where t.wfsj > to_date('2014-04-01', 'yyyy-mm-dd')
   and t.wfsj < to_date('2014-05-01', 'yyyy-mm-dd');

--两张表关联查询后修改,修改2014年4月份出租车违法数据的同步标志位
update t_veh_traffic_vio t
   set synchflag = 0, synchstatus = 'u'
 where t.wfsj > to_date('2014-04-01', 'yyyy-mm-dd')
   and t.wfsj < to_date('2014-05-01', 'yyyy-mm-dd')
   and exists (select 1
          from vhcl_info v
         where t.hphm = v.vhcl_no
           and v.vhcl_tracle = '出租车');