Having the following related tables
I need to eliminate the relationships between table4 and table1, that is, the data that exists in table1_table4 with the condition that table4's target is different from table3's target
To identify the number of affected rows I wrote this query
SELECT 
    COUNT(*)
FROM
    table2
        INNER JOIN
    table2_table3 ON table2.id = table2_table3.table2_id
        INNER JOIN
    table3 ON table3.id = table2_table3.table3_id
        INNER JOIN
    table1_table2 ON table2.id = table1_table2.table2_id
        INNER JOIN
    table1 ON table1.id = table1_table2.table1_id
        INNER JOIN
    table1_table4 ON table1.id = table1_table4.table1_id
        INNER JOIN
    table4 ON table4.id = table1_table4.table4_id
WHERE
    table3.target != table4.target;
Here I identify 149 records to be affected.
Now I need to delete the affected data in table1_table4. Could you please advise me how should I write this deletion query?
Thanks in advance

 
     
    