Author: Rachel Coin <[EMAIL PROTECTED]>
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
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]