Skip to content
Advertisement

SQL Delete all rows in a table based on another table and another column value

table1:

table2:

Let me explain better, i want to delete all ORDER ID in table 2, based on all ID of table 1 if post_status = wc-refunded

MYSQL VERSION: 5.7

EDIT: fixed with first solution from the @Tim Biegeleisen (THANKS!)

Advertisement

Answer

You could use exists logic:

We can also try using delete join logic:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement