| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Stuart Rison <rison(at)biochemistry(dot)ucl(dot)ac(dot)uk> |
| Cc: | pgsql-sql <pgsql-sql(at)postgreSQL(dot)org> |
| Subject: | Re: [SQL] self-join and DISTINCT quandry. |
| Date: | 1999-09-29 23:22:29 |
| Message-ID: | 5276.938647349@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Stuart Rison <rison(at)biochemistry(dot)ucl(dot)ac(dot)uk> writes:
> But what is I didn't want the information to appear twice. I could try
> adding DISTINCT but that would not work because row a,1,7 is of course
> DISTINCT from a,7,1 although I am looking for such duplication to be
> eliminated...
Bit of a hack, but you could add the condition
... AND t1.number < t2.number;
to get rid of the two-way duplication that otherwise arises from
your join. (Any other way of selecting just one of the pair
of matches would work as well, of course; you could compare the
two row's OIDs if nothing else was handy.)
Not sure if you still need DISTINCT after that.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 1999-09-29 23:24:26 | Re: [SQL] Date: Wed, 29 Sep 1999 23:49:15 +0300 |
| Previous Message | Ismail Kizir | 1999-09-29 20:49:15 |