Re: problem with array query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Grant Maxwell <grant(dot)maxwell(at)maxan(dot)com(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: problem with array query
Date: 2009-09-28 01:42:58
Message-ID: 12232.1254102178@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Grant Maxwell <grant(dot)maxwell(at)maxan(dot)com(dot)au> writes:
> According to the 8.3 docs I should be able to write:
> select * from tblretrain where 'ms-ap-t2-02c9' NOT IN (owners);
> where owners is an array per the following definition
> owners character varying(1024)[],

No, what you can write is "<> ALL", not NOT IN.

> It seems as though postgres is not recognising owners as an array.

It's trying to parse the literal as an array so that it can do a
plain equality comparison against the owners column.

You probably read the part of the docs where it says that
x NOT IN (SELECT ...) is equivalent to x <> ALL (SELECT ...).
Which is true, but it has nothing to do with the non-sub-SELECT syntax.
Without a sub-SELECT, we have two cases:
x NOT IN (y,z,...) expects x,y,z to all be the same type.
x <> ALL (y) expects y to be an array of x's type.
Got it?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Grant Maxwell 2009-09-28 02:15:46 Re: problem with array query
Previous Message Grant Maxwell 2009-09-28 01:27:54 problem with array query