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

Re: BUG #2889: Syntax error: WHERE ANY(arrayfield) = N

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: David Higgs <higgsd(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2889: Syntax error: WHERE ANY(arrayfield) = N
Date: 2007-01-20 02:14:17
Message-ID: 200701200214.l0K2EHd22649@momjian.us (view raw or flat)
Thread:
Lists: pgsql-bugs
David Higgs wrote:
> On 1/13/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > "David" <higgsd(at)gmail(dot)com> writes:
> > > This statement works:
> > > => SELECT * FROM sal_emp WHERE 10000 = ANY (pay_by_quarter);
> >
> > > But this does not:
> > > => SELECT * FROM sal_emp WHERE ANY (pay_by_quarter) = 10000;
> > > ERROR:  syntax error at or near "ANY" at character ...
> >
> > This is not a bug, it's the way the syntax works per SQL spec.
> > ANY must immediately follow the operator it relates to.  See
> > <quantified comparison predicate> syntax in the spec.
> >
> >                         regards, tom lane
> >
> 
> Aha, I see it in the docs now, although it's still rather unintuitive.
>  Could the appropriate section on arrays be crosslinked to the ANY/ALL
> page, to preempt this question in the future?

I researched this and found this line right above the example you quoted
above:

	An alternative method is described in Section 9.17. The above query
	could be replaced by:
	
	SELECT * FROM sal_emp WHERE 10000 = ANY (pay_by_quarter);

and section 9.17 is 9.17. Row and Array Comparisons.  Not sure we can do
any better than that.

-- 
  Bruce Momjian   bruce(at)momjian(dot)us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2007-01-20 04:54:53
Subject: Re: PostgreSQL & Slackware
Previous:From: Bruce MomjianDate: 2007-01-20 01:38:38
Subject: Re: BUG #2907: pg_get_serial_sequence quoting

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