Re: work on rows - Mailing list pgsql-sql

From dev@archonet.com
Subject Re: work on rows
Date
Msg-id 20010307.21491400@client.archonet.com
Whole thread Raw
In response to work on rows  ("Rachel Coin" <rachel@derniere-minute.org>)
List pgsql-sql
Author: Rachel Coin <rachel@derniere-minute.org>
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..
Do you mean something like the following? (PS - please don't post HTML to 
mailing lists)

richardh=> select * from cats;c
---AB
(2 rows)

richardh=> select * from subcats;c | s
---+----A | a1A | a2A | a3A | a4
(4 rows)

richardh=> select cats.c,subcats.s from cats,subcats where 
cats.c=subcats.c;c | s
---+----A | a1A | a2A | a3A | a4
(4 rows)

richardh=> select cats.c,subcats.s from cats,subcats where cats.c=subcats.c 
and subcats.s
in (select s from subcats where subcats.c=cats.c limit 2);c | s
---+----A | a1A | a2
(2rows)

- Richard Huxton


pgsql-sql by date:

Previous
From: Roland Roberts
Date:
Subject: Re: Permissons on database
Next
From: dev@archonet.com
Date:
Subject: Re: Newbie: execute function error!