Re: return records with more than one occurrences

From: Jasmin Dizdarevic <jasmin(dot)dizdarevic(at)gmail(dot)com>
To: Tarsis Lima <tarsis(dot)lima(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: return records with more than one occurrences
Date: 2011-01-07 10:07:03
Message-ID: AANLkTikOHwV56NvXZBSZ19yWOW_kVYGm=bqaik-k07pS@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

this is a good point to start.

select t2.* from table2 t2
inner join (
select id from table1
group by id
having count(*) > 1
) t1 on t2.id_table1 = t1.id

2011/1/5 Tarsis Lima <tarsis(dot)lima(at)gmail(dot)com>

> how would the SELECT to return only records with more than one
> occurrences of id_table1? example:
> -- Table1
> -- id --
> -------------------------
> 1
> 2
>
>
> -- Table2
> id --- | id_table1 | name
> ----------------------------------------------
> 4 ---- | ----- 1 ------ | Tom
> 5 ---- | ----- 1 ------ | Luci
> 6 ---- | ----- 2 ------ | Cleber ------>this can not return
>
>
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Samuel Gendler 2011-01-07 10:44:07 Re: pattern matching with dates?
Previous Message Adrian Klaver 2011-01-06 02:33:27 Re: explicit casts