delete from MySQL with outer join

Here is the code to delete records from a MySQL table with an outer join.

e.g. to delete the records from a products_to_categories table that have no product in the products table:

delete from pc
using products_to_categories as pc
left outer join products p on pc.products_id =p.products_id
where isnull(p.products_id)

Ihre Anmerkungen zu diesem Artikel

Ihre E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Sie können folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>