pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
work on rows 2+ messages / 2 participants [nested] [flat]
* work on rows @ 2001-03-07 19:06 Rachel Coin <rachel@derniere-minute.org> 2001-03-07 21:49 ` Re: work on rows dev@archonet.com 0 siblings, 1 reply; 2+ messages in thread From: Rachel Coin @ 2001-03-07 19:06 UTC (permalink / raw) To: pgsql-sql Hello, 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.. Thanks Regards, Rachel ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: work on rows 2001-03-07 19:06 work on rows Rachel Coin <rachel@derniere-minute.org> @ 2001-03-07 21:49 ` dev@archonet.com 0 siblings, 0 replies; 2+ messages in thread From: dev@archonet.com @ 2001-03-07 21:49 UTC (permalink / raw) To: Rachel Coin <rachel@derniere-minute.org>; +Cc: 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 --- 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 ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-03-07 21:49 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2001-03-07 19:06 work on rows Rachel Coin <rachel@derniere-minute.org> 2001-03-07 21:49 ` dev@archonet.com
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