MYSQL的update
多个表的UPDATE操作, 指定联合条件where UPDATE items,month SET items.price=month.price WHERE items.id=month.id; 注意:多表 UPDATE 不可以使用 ORDER BY 或 LIMIT
链接更新,,在需要中间表的时候 -- 更新一张表 UPDATE table1 t1 INNER JOIN table2 t2 ON t1.t2_id = t2.t1_id SET t1.price = t2.price * 0.8, t2.update_date = NEW () -- 同时更新两张表 UPDATE product p INNER JOIN productPrice pp ON p.productId = pp.productId SET pp.price = pp.price * 0.8, p.dateUpdate = CURDATE() WHERE p.dateCreated < '2004-01-01'
--plus: update xcs_user_credit_score a1,xcs_user_credit_score a2 set a1.user_currday_score=(case when a1.user_currday_score+10<0 then a1.user_currday_score+10 else 0 end) where a1.pt_day='2017-09-20' and a2.pt_day='2017-09-19' and a1.uid=a2.uid and (a1.seqing_score=0 and a1.user_silent_score=0 and a1.jubao_score=0 and a1.chengpaopao_score=0 and a1.weifan_score=0) and a1.user_currday_score<0 ;