Deleting rows with MySQL LEFT JOIN
If you are using "table as", then specify it to delete.
In the example i 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
This script worked for me:
DELETE t
FROM table t
INNER JOIN join_table jt ON t.fk_column = jt.id
WHERE jt.comdition_column…;
DELETE FROM deadline where ID IN (
SELECT d.ID FROM `deadline` d LEFT JOIN `job` ON deadline.job_id = job.job_id WHERE `status` = 'szamlazva' OR `status` = 'szamlazhato' OR `status` = 'fizetve' OR `status` = 'szallitva' OR `status` = 'storno');
I am not sure if that kind of sub query works in MySQL, but try it. I am assuming you have an ID column in your deadline table.
You simply need to specify on which tables to apply the DELETE
.
Delete only the deadline
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` ....