Re: array in postgre

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: gavaneh <gavaneh(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: array in postgre
Date: 2004-07-09 08:41:12
Message-ID: 1089362472.29095.42.camel@braydb
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Dmitry Karasik 2004-07-09 10:06:14 Speed of the stored procedures?
Previous Message mike g 2004-07-09 06:01:39 Re: [LONG] Need help on pg_dump!