티스토리 뷰
http://www.mysqltutorial.org/mysql-update-join/
MySQL UPDATE JOIN | Cross-Table Update in MySQL
This tutorial shows you how to perform cross-table update by using MySQL UPDATE JOIN statement with INNER JOIN and LEFT JOIN.
www.mysqltutorial.org
MySQL UPDATE JOIN syntax
We often use join clauses to query rows in a table that have (in the case of INNER JOIN) or may not have (in the case of LEFT JOIN) corresponding rows in another table. In MySQL, we can use the JOIN clauses in the UPDATE statement to perform the cross-table update.
The UPDATE LEFT JOIN statement basically updates a row in a table when it does not have a corresponding row in another table.
For example, you can increase the salary for a new hire by 1.5% using the following statement:
UPDATE employees
LEFT JOIN
merits ON employees.performance = merits.performance
SET
salary = salary + salary * 0.015
WHERE
merits.percentage IS NULL;
UPDATE 판매관리
SET 합계=(SELECT sum(합계) FROM 판매제품관리 WHERE 판매제품관리.판매ID = 판매관리.ID)
WHERE 날짜='2018-07-01'
'mysql' 카테고리의 다른 글
[mysql]날짜 (0) | 2021.05.14 |
---|---|
[mysql] 무료 mysql 보안 (0) | 2021.05.14 |
[mysql] delete / left join (0) | 2021.03.26 |