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)
 Records showing up despite statement to eliminate

Author  Topic 

omega1983
Starting Member

40 Posts

Posted - 2009-11-05 : 16:22:19
Here is my code
sELECT PhoneID,DegreeYear

from Email_Table inner join School_Table
on phnid = schlid
where schlschool = '15'
and schoolConc not in (select schoolConc
from School_Table
where schoolConc in
('7101a','7101b','7101c','7101d','7101e','7101f',
'7101g','7101i'))

The query is supposed to eliminate concentrations in parenthesis. When I run the query it shows the concentrations it is supposed to eliminate.
Is there another way I can write this or is my parenthesis in the wrong place? Should I be selecting the schoolID instead of the schoolConc in the nested select statement?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-05 : 16:40:25
I don't see the need for the subquery.

select PhoneID, DegreeYear
from Email_Table
join School_Table
on phnid = schlid
where schlschool = '15'
and schoolConc not in ('7101a','7101b','7101c','7101d','7101e','7101f',
'7101g','7101i')

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -