MySQL notes: Difference between revisions
Jump to navigation
Jump to search
(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") |
|||
Line 11: | Line 11: | ||
AND c.val > 10; | AND c.val > 10; | ||
</pre> | </pre> | ||
Another way | |||
<pre> | |||
UPDATE T1, T2, | |||
[INNER JOIN | LEFT JOIN] T1 ON T1.C1 = T2.C1 | |||
SET T1.C2 = T2.C2, | |||
T2.C3 = expr | |||
WHERE condition | |||
</pre> | |||
Revision as of 14:42, 17 May 2023
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;
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