On Fri, Jun 27, 2003 at 13:13:07 +0200, Együd Csaba <[EMAIL PROTECTED]> wrote: > Hi,
Please don't reply to messages to start a new thread. > I have a product table identified by its id field. There is a productgroups > table with productisd, productgroupid fields. And I have a prod_in_pgr > (productid, productgroupid) table which describes the membership of > productgroups. Each product can be a member of zero or more productgroups, > but one productgroup can contain a product only once. > > I would like to list the following information: > productgroupid | productid | ... some other prouduct info | ... > > I need all the products even if it is not a member in any productgroups. I > need these information ordered by productgroup and then productid. > -------------------------------- > An example: > > select t_productgroups.name as pgroup, > t_products.id as productid > from t_products > join t_prod_in_pgr on (t_products.id=productid) > join t_productgroups on (t_productgroups.id = t_prod_in_pgr.productgroupid) > order by pgroup, productid; I think you want something like: select t_productgroups.name as pgroup, t_products.id as productid from t_products left join (t_prod_in_pgr join t_productgroups on (t_productgroups.id = t_prod_in_pgr.productgroupid)) on (t_products.id=productid) order by pgroup, productid; ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match