From rachel@derniere-minute.org Wed Mar 7 19:01:49 2001 Received: from ns0.ovh.net (b1.ovh.net [213.186.33.51] (may be forged)) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f27J1nx24049 for ; Wed, 7 Mar 2001 14:01:49 -0500 (EST) (envelope-from rachel@derniere-minute.org) Received: (qmail 4913 invoked by uid 503); 7 Mar 2001 18:59:41 -0000 Received: from unknown (HELO toto) (63.123.228.200) by mail1.ha.ovh.net with SMTP; 7 Mar 2001 18:59:41 -0000 Message-ID: <00b701c0a739$c8170460$6101a8c0@spidinfo.com> From: "Rachel Coin" To: Subject: work on rows Date: Wed, 7 Mar 2001 20:06:48 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00B4_01C0A742.241044E0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-Archive-Number: 200103/157 X-Sequence-Number: 1810 This is a multi-part message in MIME format. ------=_NextPart_000_00B4_01C0A742.241044E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, I have a problem with a sql query.I have two tables : the first contains ca= tegories and the second subcategories. What kind of select may I use to get something like Yahoo! categories ( eac= h "main" category gets *at most* three sub-categories.. Thanks Regards, Rachel ------=_NextPart_000_00B4_01C0A742.241044E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello,
 
I have a problem with a sql query.I have t= wo tables=20 : the first contains categories and the second subcategories.
 
What kind of select may I use to get somet= hing like=20 Yahoo! categories ( each "main" category gets *at most* three=20 sub-categories..
 
Thanks
Regards,
 
Rachel
 
 
 
 
------=_NextPart_000_00B4_01C0A742.241044E0-- From dev@archonet.com Wed Mar 7 21:51:57 2001 Received: from www-uk-05.digiserve.com ([195.172.23.63]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f27Lpvx10021 for ; Wed, 7 Mar 2001 16:51:57 -0500 (EST) (envelope-from dev@archonet.com) Received: from mainbox.archonet.com (mwynhau.demon.co.uk [193.237.186.96]) by www-uk-05.digiserve.com (8.9.1/8.9.1) with ESMTP id VAA15382; Wed, 7 Mar 2001 21:52:59 GMT Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with SMTP id B8F712A479; Wed, 7 Mar 2001 21:49:16 +0000 (GMT) From: dev@archonet.com Date: Wed, 07 Mar 2001 21:49:14 GMT Message-ID: <20010307.21491400@client.archonet.com> Subject: Re: work on rows To: Rachel Coin Cc: Reply-To: dev@archonet.com In-Reply-To: <00b701c0a739$c8170460$6101a8c0@spidinfo.com> References: <00b701c0a739$c8170460$6101a8c0@spidinfo.com> X-Mailer: Mozilla/3.0 (compatible; StarOffice/5.2;Linux) X-Priority: 3 (Normal) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.postgresql.org id f27Lpwx10026 X-Archive-Number: 200103/159 X-Sequence-Number: 1812 Author: Rachel Coin 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