X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 55AF4D82F0 for ; Wed, 19 Oct 2005 00:35:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44512-02 for ; Wed, 19 Oct 2005 03:35:52 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 707E4D8053 for ; Wed, 19 Oct 2005 00:35:52 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j9J3ZjCd093759 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 18 Oct 2005 21:35:47 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id j9J3Ziaq066058; Tue, 18 Oct 2005 21:35:44 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id j9J3ZiiK066057; Tue, 18 Oct 2005 21:35:44 -0600 (MDT) (envelope-from mfuhr) Date: Tue, 18 Oct 2005 21:35:44 -0600 From: Michael Fuhr To: Matthew Peter Cc: paperinik 100 , pgsql-sql@postgresql.org Subject: Re: problems with array Message-ID: <20051019033544.GA66012@winnie.fuhr.org> References: <20051019030948.80709.qmail@web35201.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051019030948.80709.qmail@web35201.mail.mud.yahoo.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/208 X-Sequence-Number: 23061 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