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 2005 Forums
 Transact-SQL (2005)
 Need help writing a stored procedure...

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2008-07-11 : 14:14:19
I have a web page for a user to categorized titles in the database to go with a classification. When they select a title they next have to select classifications that go with the titles (such classifictions are Management, Quality, etc...). Those results go in the Titleclassification table.

Now the user wants a report on all of the titles that do not have a classification to see if they classified all of the titles.
How do I do this?

Here's the table and field structure:

Table Name - Titles
Field- TitleID
Field - Title


Table Name - Classifications
Field - ClassificationID
Field - Description

Table Name - Titleclassification
Field - TitleClassID
Field - ClassificationID
Field - TitleID


Tried this but it’s not giving me the right data back.

select titleclassification.titleid, titleclassification.classificationid
from titleclassification
inner join titles on titles.titleid = titleclassification.titleid
where titles.titleid <> titleclassification.classificationid

Thanks.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-07-11 : 15:32:08
try this
select ti.titleid, tc.classificationid
from
titles ti
left join
titleclassification tc
on
ti.titleid = tc.titleid
where
tc.classificationID is null


Jim
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-12 : 02:03:05
select titleid
from
titles
where titleid not in (select titleid from titleclassification)
Go to Top of Page
   

- Advertisement -