From: Michael Fuhr <mike@fuhr.org>
To: Matthew Peter <survivedsushi@yahoo.com>
Cc: paperinik 100 <paperinik_100@hotmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: problems with array
Date: Tue, 18 Oct 2005 21:35:44 -0600
Message-ID: <20051019033544.GA66012@winnie.fuhr.org> (raw)
In-Reply-To: <20051019030948.80709.qmail@web35201.mail.mud.yahoo.com>
References: <BAY108-F2573522163DF0C1FC43D0DD27C0@phx.gbl>
<20051019030948.80709.qmail@web35201.mail.mud.yahoo.com>
On Tue, Oct 18, 2005 at 08:09:48PM -0700, Matthew Peter wrote:
> Not sure if you got this figured out but I think
>
> SELECT * from tb_cat WHERE id IN (SELECT
> array_to_string(cat,',') as cat FROM tb_array WHERE
> id=1);
>
> is what your looking for?
I doubt it, considering that it doesn't work :-(
SELECT * from tb_cat WHERE id IN (SELECT
array_to_string(cat,',') as cat FROM tb_array WHERE
id=1);
id | desc
----+------
(0 rows)
This might do the trick:
SELECT c.*
FROM tb_cat AS c, tb_array AS a
WHERE c.id = ANY (a.cat) AND a.id = 1;
id | desc
----+-------
10 | cat10
20 | cat20
(2 rows)
Or if you prefer the explicit join syntax:
SELECT c.*
FROM tb_cat AS c JOIN tb_array AS a ON c.id = ANY (a.cat)
WHERE a.id = 1;
id | desc
----+-------
10 | cat10
20 | cat20
(2 rows)
--
Michael Fuhr
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: mike@fuhr.org, survivedsushi@yahoo.com, paperinik_100@hotmail.com
Subject: Re: problems with array
In-Reply-To: <20051019033544.GA66012@winnie.fuhr.org>
* 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