mysql多表关联查询进行数据修改

 问题描述:进行update某个表数据的时候,需要关联查询若干表进行筛选过滤.

 问题解决:

 UPDATE t_order_third AS t
 INNER JOIN t_order_attachment AS s ON s.forderId = t.fthirdchildId
 SET t.fuserstate = 5,
    t.fuser2state = 24,
    t.fupdated = now(),
    t.ffinished = now()

 WHERE
    s.fattachmentType = 'receipt'
    AND datediff(curdate(), s.fcreated) = 10
    AND t.fuser2state = 33
    AND t.fuserstate = 4
1;


  注意:红色字体处是更新语句主体部分,而绿色字体主要是进行关联查询,以及查询过滤条件.

  参考:http://blog.sina.com.cn/s/blog_4c197d420101aer2.html

你可能感兴趣的:(MySQL)