From: Tomasz Myrta <jasiek@klaster.net>
To: wahab@mimos.my
To: 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> (raw)
In-Reply-To: <3E4704EA.A7A813CC@mimos.my>
References: <3E4704EA.A7A813CC@mimos.my>
> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: jasiek@klaster.net, wahab@mimos.my
Subject: Re: How to delete duplicate record
In-Reply-To: <20030210071718.M78570@klaster.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox