Skip site navigation (1) Skip section navigation (2)

Re: SQL question....

From: Karl Denninger <karl(at)denninger(dot)net>
To: chester c young <chestercyoung(at)yahoo(dot)com>
Cc: sql pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: SQL question....
Date: 2008-05-20 19:17:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
chester c young wrote:
>> create table access (name text, address ip)
>> I want to construct a SELECT statement which will return ONLY tuples 
>> containing IP and name pairs IF there is an IP that has two or more 
>> NAMEs associated with it.
> many ways:
> select a1.* from access a1 where exists( 
>    select 1 from access a2 where and a1.ip!=a2.ip );
> select a1.*
> from    access a1
> join    access a2 using( name )
> where   a1.ip != a2.ip;
Those will return single entries as well (which is easy to do with an 
"ORDER BY", that is computationally simpler)

What I want (and can't figure out) is a SELECT that returns ONLY tuples 
with two or more NAME entries that have the same IP.

-- Karl

In response to


pgsql-sql by date

Next:From: Harold A. Giménez Ch.Date: 2008-05-20 19:54:11
Subject: Re: SQL question....
Previous:From: chester c youngDate: 2008-05-20 19:06:32
Subject: Re: SQL question....

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group