Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQL query help needed

0 views
Skip to first unread message

Annie So

unread,
Oct 17, 2000, 3:00:00 AM10/17/00
to
Hi All,

I need to generate the following for my webpage,


This is a list of resrouces for CATEGORY_1

SUBCATEGORY_A
URL_A1
URL_A2
URL_A3

SUBCATEGORY_B
URL_B1
URL_B2
URL_B3

I have three tables, a URL table which has the url and subcategoryId, a
subcat table, which has the subcatId and subcatName, and a to-many
urlcat table, which has url and categoryId.

I tried

SELECT subcategoryId FROM libUrl
WHERE EXISTS (SELECT subcatName, subcatId FROM libSubcat
WHERE subcatId = subcategoryId)
GROUP BY subcategoryId

But it does not seem to be working. What's wrong?

TIA,
Annie

Thomas R. Hummel

unread,
Oct 17, 2000, 3:00:00 AM10/17/00
to
What are you trying to do? The columns in your select statement don't
match up at all to the output that you say that you want. You don't
have the urlcat table mentioned at all in your select statement, but it
looks like you want your output to be limited by that given your sample
output.

Given your brief description of your tables and the expected output
I'll take a guess at what you're looking for, but I might be way off.

SELECT s.subcatID, s.subcatName, u.url
FROM urlcat uc
INNER JOIN url u ON u.url = uc.url
INNER JOIN subcat s on s.subcatID = u.subcategoryID
WHERE uc.categoryID = @CategoryID
ORDER BY s.subcatName

It's just a guess, but maybe it's close to what you're looking for and
will point you in the right direction.

Good luck,
-Tom.

In article <39EC76EF...@mail.utexas.edu>,


Sent via Deja.com http://www.deja.com/
Before you buy.

0 new messages