SQL Query To Delete With Join

Usually our SQL queries use JOINs in SELECT queries. But what about if you want to DELETE using a JOIN? It’s not as straightforward.

You Have To Use A *

To tell MySQL which table you want to delete records from you must specify table.* like so:

DELETE product.*
FROM product p
LEFT JOIN productPrice pp
ON p.productId = pp.productId
WHERE pp.productId IS NULL

Further details and examples can be found at Cross Table Delete with MySQL.

Leave a Reply

Your email address will not be published. Required fields are marked *