I have three tables, that match the following diagram:
And I need to delete some data from join_table, where a label column(table_right) and name column(table_left) match some criteria.
My solution is to use a temporary table:
create temporary table if not exists data_for_deletion
(select jt.id
from join_table jt
left join table_left tableLeft on jt.table_left_id = tableLeft.id
left join table_right tableRight on jt.table_right_id = tableRight.id
where tableLeft.name = 'name' and tableRight.label = 'label');
delete from join_table where id in (select id from data_for_deletion);
My question is: is there any other way to do such deletion without creating a temporary table?