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)
 SQL statement NOT IN with OR

Author  Topic 

avashl
Starting Member

2 Posts

Posted - 2008-03-27 : 15:19:56
I have a column "Description" in table called "Standards" and I have column "Standard1", "Standard2" and "Standard3" in Table called "Content".

I want to select all the records in "Description" column of table "Standards" that is not in columns "Standard1" or "Standard2" or "Standard3". Right now I am able to select all records in "Description" that is not in "Standard1" by using the following code:

select st.description from Standards st where st.description not in (select standard1 from Content)

Is there way I can not only look at "Standard1" column but also "Standard2" and "Standard3"

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-27 : 15:24:00
select st.description from Standards st where st.description not in
(select standard1 from Content
union all
select standard2 from Content
union all
select standard3 from Content
)
Go to Top of Page

avashl
Starting Member

2 Posts

Posted - 2008-03-27 : 15:30:15
That worked great. Thanks.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-27 : 15:33:12
You are welcome
Go to Top of Page
   

- Advertisement -