From: Peter Brawley Date: June 27 2006 6:12pm Subject: Re: DELETE based on JOIN List-Archive: http://lists.mysql.com/mysql/199398 Message-Id: <44A17528.2000703@earthlink.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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