SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Select Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

anishap
Yak Posting Veteran

61 Posts

Posted - 09/17/2010 :  15:54:23  Show Profile  Reply with Quote
I have a table with column TYPE1, TYPE2, TYPE3, TYPE4. I want to select rows that doesn't have 'METALS' in any of these 4 columns.

I tried to query using 'OR' OPERATOR but it won't work.

Can any one help me with this?

Thanks

Vinnie881
Flowing Fount of Yak Knowledge

USA
1222 Posts

Posted - 09/17/2010 :  15:59:41  Show Profile  Reply with Quote
you want a AND operator not OR

Slect * from mytable where
not type1 = 'METALS'
and
not type2 = 'METALS'
and
not type3 = 'METALS'
and
not type4 = 'METALS'



Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 09/18/2010 :  09:14:22  Show Profile  Reply with Quote
i prefer using column <> rather than not column =

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

rohitvishwakarma
Posting Yak Master

India
232 Posts

Posted - 09/20/2010 :  05:39:31  Show Profile  Reply with Quote
SELECT * FROM mytable WHERE
type1 <> 'METALS' AND
type2 <> 'METALS' AND
type3 <> 'METALS' AND
type4 <> 'METALS'
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000