From: Dawid Kuroczko <qnex42@gmail.com>
To: josh@agliodbs.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Subselects returning array and ANY...
Date: Thu, 28 Feb 2008 01:34:42 +0100
Message-ID: <758d5e7f0802271634q7d8bbdc0t29cb94e932526f22@mail.gmail.com> (raw)
In-Reply-To: <200802271611.50928.josh@agliodbs.com>
References: <758d5e7f0802271601m592a932bh5916b10eccecbb4a@mail.gmail.com>
<200802271611.50928.josh@agliodbs.com>
On Thu, Feb 28, 2008 at 1:11 AM, Josh Berkus <josh@agliodbs.com> wrote:
> Dawid,
> > 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.
>
> Drop the second SELECT, I think.
>
> postgres=# select 'x' = ANY ( '{x,y,z}'::TEXT[] );
> ?column?
> ----------
> t
Probably I didn't make myself clear enough. :) I know this works (see
above two examples).
I need to connect two tables, one is:
CREATE TEMP TABLE haystack (straw text);
INSERT INTO haystack SELECT n FROM generate_series(1,100) AS x(n);
CREATE TEMP TABLE needles (id int, straws text[]);
INSERT INTO needles VALUES (1, '{10,15,aaa}');
SELECT * FROM haystack WHERE straw = ANY (SELECT straws FROM needles
WHERE id=1);
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.
But you are right, though! I just need to leave off the subselect! Thanks!
SELECT h.* FROM haystack h JOIN needles ON straw = ANY (straws);
(not exactly what I was looking for, but it works ;))
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: qnex42@gmail.com, josh@agliodbs.com
Subject: Re: Subselects returning array and ANY...
In-Reply-To: <758d5e7f0802271634q7d8bbdc0t29cb94e932526f22@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox