Re: Array with Subselect / ANY - cast? - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Array with Subselect / ANY - cast?
Date
Msg-id 162867790708211115k26f4b266m25493d841af4405a@mail.gmail.com
Whole thread Raw
In response to Array with Subselect / ANY - cast?  (Josh Trutwin <josh@trutwins.homeip.net>)
Responses Re: Array with Subselect / ANY - cast?
List pgsql-general
Hello

2007/8/21, Josh Trutwin <josh@trutwins.homeip.net>:
> Hi - I have the following array field:
>
> SELECT pb_ids FROM pb WHERE id = 123:
>
>          pb_id
> -----------------------
>  {196,213,215,229,409}
>
> These numbers map to a productid in tblproducts so I figured I could
> do this:
>
> SELECT *
>   FROM tblproducts
>  WHERE productid = ANY (
>        SELECT pb_ids FROM pb WHERE id=123
>  );
>

SELECT * FROM ... WHERE 1000 IN (SELECT pb_ids FROM pb WHERE id=123)

or

SELECT * FROM ... WHERE 1000 = ANY(ARRAY(SELECT pb_ids FROM pb WHERE id=123))


Pavel

pgsql-general by date:

Previous
From: Josh Trutwin
Date:
Subject: Array with Subselect / ANY - cast?
Next
From: "Robin Helgelin"
Date:
Subject: history table