MySQL notes: Difference between revisions
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
===Notes for working with MySQL=== | ===Notes for working with MySQL=== | ||
Basic table join for update with where clause | Basic table join for update from one table to another with where clause | ||
<pre> | <pre> | ||
UPDATE tableA a | UPDATE tableA a |
Revision as of 14:43, 17 May 2023
Notes for working with MySQL
Basic table join for update from one table to another 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;
Another way
UPDATE T1, T2, [INNER JOIN | LEFT JOIN] T1 ON T1.C1 = T2.C1 SET T1.C2 = T2.C2, T2.C3 = expr WHERE condition