Subselects returning array and ANY...

From: "Dawid Kuroczko" <qnex42(at)gmail(dot)com>
To: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Subselects returning array and ANY...
Date: 2008-02-28 00:01:57
Message-ID: 758d5e7f0802271601m592a932bh5916b10eccecbb4a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

A simple text case

=# CREATE TEMP TABLE foo (t text);
CREATE TABLE
=# INSERT INTO foo SELECT 'x'||n FROM generate_series(1,100) AS x(n);
INSERT 0 100

This works:
SELECT * FROM foo WHERE t = ANY ('{x4,5,zzz}'::text[]);

And this works too:
SELECT * FROM foo WHERE t IN (SELECT t FROM foo LIMIT 5);

...now, what am I doing wrong with this query?

SELECT * FROM foo WHERE t = ANY (SELECT '{x4,5,zzz}'::text[]);
ERROR: operator does not exist: text = text[]
HINT: No operator matches the given name and argument type(s). You
might need to add explicit type casts.

I have a table containing text array field, and I want to use this
field in subselect...
I know it must be simple... (without defining new operators).

Thanks in advance!

Dawid

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2008-02-28 00:11:50 Re: Subselects returning array and ANY...
Previous Message miquel_ibanez 2008-02-27 22:40:45 operator class