mysql update連表

UPDATE price_air_item t1 LEFT JOIN order_item t2 ON t1.ORDER_ITEM_ID = t2.ORDER_ITEM_ID SET t1.BUYER_SHOULD_PAY_AMOUNT = t1.PARTNER_ADJ_TOTAL_AMOUNT WHERE t2.CREATED_REQUEST_TYPE = 'LOTTO-OTA' AND t2.CREATED_BY ='LOTTO-OTA' AND t1.GMT_CREATED = '2017-12-06 14:02:00'app

 

 

正常的寫法是 update  table set field ='' where  id=(select   ***************條件);.net

例如:blog

 

update  tb_wd_rpmtplan_base  r  set r.SHD_RPMT_DATE='2018-03-11' ,r.id='dfasdf'it

where r.PROJECT_ID=(
select p.id from tb_zc_project_info p
join tb_wd_loanapply_base lb on lb.project_id=p.id
where lb.APPLY_NUM='RY201803111340200'
  );table

可是須要join on的語法我嘗試好久,都是寫不對的,若是咱們必定要用到 left join 更新,那麼怎麼寫呢。我老是在網上看到例子了。date

語法是:file

update  table  t1 (left) join   table2 t2 on  ( t1.id=t2.pid )set ti.fiele='' where t2.filed='' select

例如:語法

UPDATE tb_wd_rpmtplan_base r
LEFT JOIN  tb_zc_project_info p
ON r.PROJECT_ID=r.ID
set r.SHD_RPMT_DATE='2018-03-11'apply

where p.id='dfsadf'

相關文章
相關標籤/搜索