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

Re: SQL question....

From: chester c young <chestercyoung(at)yahoo(dot)com>
To: Karl Denninger <karl(at)denninger(dot)net>
Cc: sql pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: SQL question....
Date: 2008-05-20 19:06:32
Message-ID: 624694.72418.qm@web54303.mail.re2.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-sql
> 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 a2.name=a2.name and a1.ip!=a2.ip );

select a1.*
from    access a1
join    access a2 using( name )
where   a1.ip != a2.ip;




      

In response to

Responses

pgsql-sql by date

Next:From: Karl DenningerDate: 2008-05-20 19:17:34
Subject: Re: SQL question....
Previous:From: Karl DenningerDate: 2008-05-20 18:14:47
Subject: SQL question....

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