Re: Getting one row for each subquery row...?

Поиск
Список
Период
Сортировка
От Tomasz Myrta
Тема Re: Getting one row for each subquery row...?
Дата
Msg-id 3EF2A496.40505@klaster.net
обсуждение исходный текст
Ответ на Getting one row for each subquery row...?  (Együd Csaba <csegyud@freemail.hu>)
Список pgsql-sql
Dnia 2003-06-20 07:12, Użytkownik Együd Csaba napisał:
> Hi All,
>  here are my three tables. I wold like to list them in the following way: I
>  need all the columns from t_stockchanges, and one field for the
> productgroup
>  the t_stockchanges.productid belongs to.
> 
>  But one product can belong to many groups, so i would need one row for each
>  group for each product.
> 
>  My bad query is:
>  ------------------------
>  DB=# select t_stockchanges.productid, (select name from t_productgroups
>  where id=(select productgroupid from t_prod_in_pgr where
>  productid=t_stockchanges.productid)) as pgroup from t_stockchanges;
>  ERROR:  More than one tuple returned by a subselect used as an expression.
>  DB=#
>  ---------------
>  Yes, this is absolutelly true, but I would like postgres to give me all the
>  tuples found. How can I ask him to do so?
> 
>  Thank you,
>  -- Csaba
> 
Sure, use "limit 1" in a subquery.

"limit" and "offset" are well described in Postgresql documentation.

Regards,
Tomasz Myrta





В списке pgsql-sql по дате отправления:

Предыдущее
От: Együd Csaba
Дата:
Сообщение: Getting one row for each subquery row...?
Следующее
От: Tomasz Myrta
Дата:
Сообщение: Re: Getting one row for each subquery row...?