From: dev@archonet.com
To: Rachel Coin <rachel@derniere-minute.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: work on rows
Date: Wed, 07 Mar 2001 21:49:14 GMT
Message-ID: <20010307.21491400@client.archonet.com> (raw)
In-Reply-To: <00b701c0a739$c8170460$6101a8c0@spidinfo.com>
References: <00b701c0a739$c8170460$6101a8c0@spidinfo.com>
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
---
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, rachel@derniere-minute.org
Subject: Re: work on rows
In-Reply-To: <20010307.21491400@client.archonet.com>
References: <00b701c0a739$c8170460$6101a8c0@spidinfo.com> <20010307.21491400@client.archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox