Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Select query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-06-17 : 15:03:29
user writes "I have three tables like
tblcategory,tblforum,tbltopic
tblcategory contains all the categories
tblforum contains forums under the categories.
tbltopic contains topics under the forums.
I want to display all topics based on forums and categories.
i need stored procedure for that

my tables are
tblcategory
----------
Cat_ID cat_name
Cat_order

tblforum
--------
Forum_ID
Cat_id
Forum_Order
Forum_name
Forum_description
Date_Started
....
tbltopic
---------
Topic_ID
Forum_ID
Subject
Start_date
Last_entry_date
..."

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-06-17 : 15:17:32
So what would the expected result set look like?

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-06-17 : 15:41:46
Just join the tables together on the ids?



Brett

8-)
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-06-17 : 17:48:24
CREATE PROCEDURE whatisgoingonhere

@forum VARCHAR(666),
@category VARCHAR(666)

AS

SELECT
t.Topic_ID,
t.Forum_ID,
t.Subject
FROM
tblcategory c
INNER JOIN tblforum f ON c.Cat_id = f.Cat_id
INNER JOIN tbltopic t ON f.Forum_ID = t.Forum_ID
WHERE
c.cat_name = @category
AND f.Forum_name = @forum

You should consider being more standardized with how you name things. :)

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -