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 2008 Forums
 Transact-SQL (2008)
 How do you use Or operator like in and not it

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-02-09 : 11:01:49
When i have multiple and conditions i can use in, this way:

WHERE People.Name in ('Jeff','Bill','Pete','Eddy','John Doe','Mike')

Using not in

WHERE People.Name not in ('Jeff','Bill','Pete','Eddy','John')


How can i use 'OR' operator similar to the above:
where Myorderhistory Or('AD345','TRY234',JACOBS32')

Thank you very much for the helpful info.

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-09 : 11:27:14
WHERE People.Name in ('Jeff','Bill','Pete','Eddy','John Doe','Mike')
this is not performing AND

Rather its a form of OR and can be rewritten as

Where
(people.name ='Jeff' OR
people.name ='Bill' OR
people.name ='pate' OR
people.name ='abc' OR
people.name ='xyz')
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-02-09 : 13:53:54
I have almost 16 fields to use 'or' - is there an easy way on the sql server sp.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-02-09 : 14:10:57
Using IN is probably easiest or maybe even making a table of the "Good" values.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-02-09 : 15:43:59
How do you use in with OR operator?

I am looking for something easy if using In is possible. can you please provide an example.

Thank you.
Go to Top of Page
   

- Advertisement -