[SQL] work on rows

2001-03-07 Thread Rachel Coin



Hello,
 
I have a problem with a sql query.I have two tables 
: the first contains categories and the second subcategories.
 
What kind of select may I use to get something like 
Yahoo! categories ( each "main" category gets *at most* three 
sub-categories..
 
Thanks
Regards,
 
Rachel
 
 
 
 


[SQL] Categories and subcategories

2001-03-20 Thread Rachel Coin

Hi,

I have two tables : the first for categories and the second for
subcategories.I want to get a result like Yahoo! For each category , the sql
query must return maximum 3 subcategories. I can't use "limit" in a subquery
because I use Postgresql 7.0.

Any help?

Regards,


Rachel


---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl



[SQL] Categories and subcategories : more details

2001-03-20 Thread Rachel Coin

> I have two tables : the first for categories and the second for
> subcategories.I want to get a result like Yahoo! For each category ,
> the sql
> query must return maximum 3 subcategories. I can't use "limit" in a
> subquery
> because I use Postgresql 7.0.

Examples : 

table CATEG :
ida categ
 1X
 2Y
 3Z 

table SUBCATEG :
idb subcateg  ida
1   x1 1
2   x2 1
3   x3 1
4   x4 1
5   y1 2
6   y2 2
7   z1 3

I 'd like to obtain a table with maximum 2 subcateg per categ :

table result :

categ subcateg
  X   x1
  X   x2
  Y   y1
  Y   y2
  Z   z1


any help?

Regards,


Rachel
 


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly