Re: problems with array
От | Michael Fuhr |
---|---|
Тема | Re: problems with array |
Дата | |
Msg-id | 20051019033544.GA66012@winnie.fuhr.org обсуждение исходный текст |
Ответ на | Re: problems with array (Matthew Peter <survivedsushi@yahoo.com>) |
Ответы |
Re: problems with array
|
Список | pgsql-sql |
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 | cat1020 | 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 | cat1020 | cat20 (2 rows) -- Michael Fuhr
В списке pgsql-sql по дате отправления: