Tuesday, 23 March 2021

MYSQL delete with left Join && nested query


https://www.mysqltutorial.org/mysql-subquery/

nested query


SELECT lastName, firstName FROM employees WHERE officeCode IN (SELECT officeCode FROM offices WHERE country = 'USA');



https://stackoverflow.com/questions/2763206/deleting-rows-with-mysql-left-join 

Delete only the deadline table rows:

DELETE `deadline` FROM `deadline` LEFT JOIN `job` ....

Delete the deadline and job rows:

DELETE `deadline`, `job` FROM `deadline` LEFT JOIN `job` ....

Delete only the job rows:

DELETE `job` FROM `deadline` LEFT JOIN `job` ....

delete all table_1 rows which are do not exists in table_2.

DELETE t1 FROM `table_1` t1 LEFT JOIN `table_2` t2 ON t1.`id` = t2.`id` WHERE t2.`id` IS NULL

No comments:

Post a Comment