Usually our SQL queries use JOIN
s 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.