Re: SQL question....
| От | Harold A. Giménez Ch. |
|---|---|
| Тема | Re: SQL question.... |
| Дата | |
| Msg-id | c807ef1a0805201254m26c765fdla975ccbc4eb13d76@mail.gmail.com обсуждение |
| Ответ на | Re: SQL question.... (Karl Denninger <karl@denninger.net>) |
| Список | pgsql-sql |
I think this is what you're looking for:
SELECT * FROM access
WHERE ip IN(SELECT ip FROM access
GROUP BY ip HAVING count(*) > 1)
SELECT * FROM access
WHERE ip IN(SELECT ip FROM access
GROUP BY ip HAVING count(*) > 1)
On Tue, May 20, 2008 at 3:17 PM, Karl Denninger <karl@denninger.net> wrote:
chester c young wrote:Those will return single entries as well (which is easy to do with an "ORDER BY", that is computationally simpler)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;
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
В списке pgsql-sql по дате отправления: