サンプルコード
UPDATE users as u INNER JOIN schools as s ON s.id = u.school_id
SET age = 18
WHERE s.name = "high school" AND s.class = "3A";
users
id | name | age | school_id |
---|---|---|---|
1 | A | 17 | 1 |
2 | B | 15 | 2 |
3 | C | 16 | 3 |
4 | D | 16 | 1 |
↓
id | name | age | school_id |
---|---|---|---|
1 | A | 18 | 1 |
2 | B | 15 | 2 |
3 | C | 16 | 3 |
4 | D | 18 | 1 |
schools
id | name | class |
---|---|---|
1 | high school | 3A |
2 | junior high school | 3A |
3 | high school | 1B |