List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:June 27 2006 6:12pm
Subject:Re: DELETE based on JOIN
View as plain text  
Jesse wrote:
> 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;
Lose the first FROM.

PB.
>
> Basically, I'm trying to delete orphan records.  I'm using MySQL 5.
>
> Thanks,
> Jesse
>


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.5/376 - Release Date: 6/26/2006

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