MySQL notes

From I Will Fear No Evil
Revision as of 15:42, 17 May 2023 by Chubbard (talk | contribs) (Created page with "===Notes for working with MySQL=== Basic table join for update with where clause <pre> UPDATE tableA a JOIN tableB b ON a.a_id = b.a_id JOIN tableC c ON b.b_id = c.b_id SET b.val = a.val+c.val WHERE a.val > 10 AND c.val > 10; </pre> Category:MySQL")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Notes for working with MySQL

Basic table join for update with where clause

UPDATE tableA a
  JOIN tableB b
    ON a.a_id = b.a_id
  JOIN tableC c
    ON b.b_id = c.b_id
   SET b.val = a.val+c.val
 WHERE a.val > 10
   AND c.val > 10;