Re: Search for lists - Mailing list pgsql-general

From Gavin Flower
Subject Re: Search for lists
Date
Msg-id 4DFE9F01.8080901@archidevsys.co.nz
Whole thread Raw
In response to Search for lists  (Daron Ryan <daron.ryan@gmail.com>)
List pgsql-general
[...]
 > I need to search a table to find sets of rows that have a column
matching
 > itself for the whole set and another column matching row for row with a
 > list I am going to supply. The result I should receive should be
value of
 > the column that matches itself.
[...]

How about:

DROP TABLE IF EXISTS T;

CREATE TABLE T
(
     id  int,
     val int
);

INSERT INTO T (id, val) VALUES
(3,  1),
(3,  2),
(4,  8),
(4,  9),
(4,  10);

SELECT
     id
FROM
     T
GROUP BY
     id
HAVING
     array_agg(val) = ARRAY[8, 9, 10];


pgsql-general by date:

Previous
From: Amitabh Kant
Date:
Subject: Re: PostgreSQL 8.4.8 bringing my website down every evening
Next
From: BangarRaju Vadapalli
Date:
Subject: Re: random backend crashes - how to debug ( Is crash dump handler released ? )