List:General Discussion« Previous MessageNext Message »
From:Jesse Date:June 27 2006 6:01pm
Subject:DELETE based on JOIN
View as plain text  
I need to delete some records based on a JOIN relation.  The following works 
in Microsoft SQL Server, and the syntax appears to be correct for MySQL, but 
it reports "syntax..near 'DELETE FROM ConvInvDet FROM ConvInvDet H...". 
What's the proper way to format this for MySQL?

DELETE FROM ConfInvDet
FROM ConfInvDet H LEFT JOIN ConfInvoices I ON I.InvoiceNo=H.InvoiceNo
WHERE I.ID IS NULL;

Basically, I'm trying to delete orphan records.  I'm using MySQL 5.

Thanks,
Jesse 

Thread
DELETE based on JOINJesse27 Jun
  • Re: DELETE based on JOINPeter Brawley27 Jun