Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group