From: | "Dawid Kuroczko" <qnex42(at)gmail(dot)com> |
---|---|
To: | josh(at)agliodbs(dot)com |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Subselects returning array and ANY... |
Date: | 2008-02-28 00:34:42 |
Message-ID: | 758d5e7f0802271634q7d8bbdc0t29cb94e932526f22@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, Feb 28, 2008 at 1:11 AM, Josh Berkus <josh(at)agliodbs(dot)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 ;))
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2008-02-28 00:45:21 | Re: Subselects returning array and ANY... |
Previous Message | Josh Berkus | 2008-02-28 00:11:50 | Re: Subselects returning array and ANY... |