Re: Array with Subselect / ANY - cast?

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Josh Trutwin" <josh(at)trutwins(dot)homeip(dot)net>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Array with Subselect / ANY - cast?
Date: 2007-08-21 18:15:59
Message-ID: 162867790708211115k26f4b266m25493d841af4405a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

2007/8/21, Josh Trutwin <josh(at)trutwins(dot)homeip(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robin Helgelin 2007-08-21 18:20:38 history table
Previous Message Josh Trutwin 2007-08-21 17:49:04 Array with Subselect / ANY - cast?