自己留备份,不解释.

UPDATE t_dealer_balance A,t_purchase_payment B
 SET A.`creator`=B.`creator`,A.CREATE_TIME=B.CREATE_TIME
 WHERE A.bill_id=B.pay_purchase_id
  and a.CREATE_TIME is null and A.`type`='CGF';

UPDATE t_dealer_balance a,t_sale_outbound b set a.remarks=concat('被反冲单号:',b.BACKFLUSH_NO)

where a.bill_Id=b.sale_outbound_id and a.`type`='SCK' AND b.`type`='02'; 

UPDATE t_dealer_balance a,`t_sale_payment` b set a.remarks=concat('被反冲单号:',b.`MINUS_BILL_ID`)

where a.bill_Id=b.`SALE_PAYMENT_ID` and a.`type`='SSK' AND b.`bill_type`='02'; 

UPDATE t_dealer_balance a,`t_purchase_stocking` b set a.remarks=concat('被反冲单号:',b.`MINUS_BILL_ID`)

where a.bill_Id=b.`STOCKING_ID` and a.`type`='CGJ' AND b.`type`='02';  

UPDATE t_dealer_balance a,`t_purchase_payment` b set a.remarks=concat('被反冲单号:',b.`MINUS_BILL_ID`)

where a.bill_Id=b.`PAY_PURCHASE_ID` and a.`type`='CGF' AND b.`BILL_type`='02'; 

UPDATE t_dealer_balance a,`t_purchase_returns` b set a.remarks=concat('被反冲单号:',b.`MINUS_BILL_ID`)

where a.bill_Id=b.`PUR_RETURN_ID` and a.`type`='CGT' AND b.`BILL_type`='02';  

UPDATE t_dealer_balance a,`t_agent_return` b set a.remarks=concat('被反冲单号:',b.`RETURNS_ORDER_ID`)

where a.bill_Id=b.`AGENT_RETURN_ID` and a.`type`='DLT' AND b.`BILL_type`='02'; 

UPDATE t_dealer_balance a,`t_agent_pay_return` b set a.remarks=concat('被反冲单号:',b.`MINUS_BILL_ID`)

where a.bill_Id=b.`AGENT_RETURN_PAY_ID` and a.`type`='DTH' AND b.`BILL_type`='02'; 

UPDATE t_dealer_balance a,`t_pur_pay_return` b set a.remarks=concat('被反冲单号:',b.`MINUS_BILL_ID`)

where a.bill_Id=b.`PAY_PUR_RETURN_ID` and a.`type`='CTH' AND b.`BILL_type`='02';  

UPDATE `t_dealer_balance` set `REMARKS`='其他收款' where `BILL_ID` in(select `OTHER_INOUT_ID` from `t_other_inout` where `TYPE`='01');

UPDATE `t_dealer_balance` set `REMARKS`='其他付款' where `BILL_ID` in(select `OTHER_INOUT_ID` from `t_other_inout` where `TYPE`='02'); 

原文地址:https://www.cnblogs.com/kaixuanpisces/p/1884610.html