From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Keith Parks <emkxp01(at)mtcc(dot)demon(dot)co(dot)uk> |
Cc: | hackers(at)postgresql(dot)org |
Subject: | Re: [HACKERS] Table aliases in delete statements? |
Date: | 1999-12-08 01:05:18 |
Message-ID: | 199912080105.UAA18591@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> >Don't use s1. Just refer to native deltest in the subquery. That
> >should reference the outer table.
>
> That doesn't seem to work as 3 rows are deleted and not just the
> two duplicates.
>
> emkxp01=> delete from deltest where respdate not in ( select min(s2.respdate)
> from deltest s2 where sessionid = s2.sessionid);
> DELETE 3
> emkxp01=> select * from deltest;
> sessionid | respdate
> -----------+------------------------------
> 1 | Tue 07 Dec 22:32:01 1999 GMT
> (1 row)
No. Use:
emkxp01=> delete from deltest where respdate not in ( select min(s2.respdate)
from deltest s2 where deltest.sessionid = s2.sessionid);
^^^^^^^
--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Lamar Owen | 1999-12-08 02:46:40 | Re: [HACKERS] perl-DBD-Pg (was Re: BOUNCE pgsql-ports@postgreSQL.org: Non-member submission from[Joe Brenner <doom@kzsu.stanford.edu>] (fwd)) |
Previous Message | Keith Parks | 1999-12-08 00:52:03 | Re: [HACKERS] Table aliases in delete statements? |