Re: How to find records with the same field?

From: "Peter Alberer" <h9351252(at)obelix(dot)wu-wien(dot)ac(dot)at>
To: "'Joost Kraaijeveld'" <J(dot)Kraaijeveld(at)Askesis(dot)nl>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to find records with the same field?
Date: 2004-07-20 10:03:15
Message-ID: 000301c46e40$c9de5510$5be0d089@ekelhardt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi joost,

I think the following should work:

include the table 2 times in your query and join the two instances in
the query by the 3 columns.

Example:

Select
t1. column4, t1.column1, t1.column2, t1.column3
From
yourtable t1, yourtable t2
Where
t1.column1 = t2.column1
and t1.column2 = t2.column2
and t1.column3 = t2.column3
order by
t1.column4;

>-----Ursprüngliche Nachricht-----
>Von: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-
>owner(at)postgresql(dot)org] Im Auftrag von Joost Kraaijeveld
>Gesendet: Dienstag, 20. Juli 2004 11:39
>An: pgsql-general(at)postgresql(dot)org
>Betreff: [GENERAL] How to find records with the same field?
>
>I have a table with column1, column2, column3 and column4. How do I get
all
>records, sorted by column4 that have the same column1,column2 and
column3?
>
>TIA
>
>
>
>Joost
>
>
>---------------------------(end of
broadcast)---------------------------TIP
>9: the planner will ignore your desire to choose an index scan if your
>joining column's datatypes do not match

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joost Kraaijeveld 2004-07-20 10:37:50 Re: How to find records with the same field?
Previous Message Devrim GUNDUZ 2004-07-20 09:46:45 Re: How to find records with the same field?