Re: array in postgre - Mailing list pgsql-novice

From Oliver Elphick
Subject Re: array in postgre
Date
Msg-id 1089362472.29095.42.camel@braydb
Whole thread Raw
In response to array in postgre  (gavaneh <gavaneh@yahoo.com>)
List pgsql-novice
On Thu, 2004-07-08 at 06:20, gavaneh wrote:
> Hi
>
> suppose we have the following query:
> select ....from ...where...and x *=3;
>
> "x" is an integer array,here we want to check whether
> "x" contains 3 or not,this is the same as one of
> postgre documentaion example,however it doesnt
> work.(why???)
>
> should I set any option? any idea?

From the documentation:

        9.17.3. ANY/SOME (array)
        expression operator ANY (array expression)
        expression operator SOME (array expression)

        The right-hand side is a parenthesized expression, which must
        yield an array value. The left-hand expression is evaluated and
        compared to each element of the array using the given operator,
        which must yield a Boolean result. The result of ANY is "true"
        if any true result is obtained. The result is "false" if no true
        result is found (including the special case where the array has
        zero elements).

        SOME is a synonym for ANY

So in your case:
SELECT ... FROM .. WHERE ... 3 = ANY (x);


Oliver Elphick


pgsql-novice by date:

Previous
From: mike g
Date:
Subject: Re: [LONG] Need help on pg_dump!
Next
From: Dmitry Karasik
Date:
Subject: Speed of the stored procedures?