From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | greg(at)turnstep(dot)com |
Cc: | pgsql-patches(at)postgresql(dot)org |
Subject: | Re: FAQ addition: deleteing all but one unique row |
Date: | 2003-02-10 15:25:36 |
Message-ID: | 5496.1044890736@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
greg(at)turnstep(dot)com writes:
> + <PRE>
> + DELETE FROM mytable WHERE ctid !=
> + (SELECT ctid FROM mytable WHERE id=12 LIMIT 1);
> + </PRE>
> +
> + <P>In the above example, all rows in the table named 'mytable' having a value
> + of 12 in the 'id' column will be deleted except for one.
You haven't actually tested this advice, have you?
The delete as given will delete all but one row, full stop.
Or at least it would if it worked at all. There's no != operator
defined for CTID. (You could get around that with "NOT ctid =".)
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | greg | 2003-02-10 15:34:52 | Re: FAQ addition: deleteing all but one unique row |
Previous Message | greg | 2003-02-10 15:12:36 | FAQ addition: deleteing all but one unique row |