Re: work on rows

From: dev(at)archonet(dot)com
To: Rachel Coin <rachel(at)derniere-minute(dot)org>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: work on rows
Date: 2001-03-07 21:49:14
Message-ID: 20010307.21491400@client.archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Author: Rachel Coin <rachel(at)derniere-minute(dot)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
---
A
B
(2 rows)

richardh=> select * from subcats;
c | s
---+----
A | a1
A | a2
A | a3
A | a4
(4 rows)

richardh=> select cats.c,subcats.s from cats,subcats where
cats.c=subcats.c;
c | s
---+----
A | a1
A | a2
A | a3
A | 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 | a1
A | a2
(2rows)

- Richard Huxton

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Kyle 2001-03-07 23:13:50 A query that doesn't work on 7.1
Previous Message dev 2001-03-07 21:41:27 Re: Newbie: execute function error!