X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ABFA747595A for ; Mon, 10 Feb 2003 01:24:51 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id F20B6475956 for ; Mon, 10 Feb 2003 01:24:50 -0500 (EST) Received: from lamer.pl (localhost [127.0.0.1]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 56F312B883; Mon, 10 Feb 2003 07:17:18 +0100 (CET) From: "Tomasz Myrta" To: wahab@mimos.my, pgsql-sql@postgresql.org Subject: Re: How to delete duplicate record Date: Mon, 10 Feb 2003 07:17:18 +0800 Message-Id: <20030210071718.M78570@klaster.net> In-Reply-To: <3E4704EA.A7A813CC@mimos.my> References: <3E4704EA.A7A813CC@mimos.my> X-Mailer: Open WebMail 1.62 20020221 X-OriginatingIP: 217.96.97.138 (jasiek) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/185 X-Sequence-Number: 11583 > How do I delete a duplicated records? > Here I've 7 duplicated records and tried to delete 6 from them. > > I tried this query but has error > b2b=> delete from biztypes where bizid = (select bizid from biztypes > where bizid = 'B116' limit 6); > ERROR: More than one tuple returned by a subselect used as an > expression. > > I tried this query, but all records are deleted. > b2b=> delete from biztypes where bizid = (select bizid from biztypes > where bizid = 'B116' limit 1); > DELETE 7 > > Any help are very much appreciated.. > Thanks. Wahab Try this: delete from biztypes where exists (select * from biztypes b2 where biztypes.bizid=b2.bizid) Regards, Tomasz Myrta