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 2000 Forums
 Transact-SQL (2000)
 Where = is more than one value

Author  Topic 

dougancil
Posting Yak Master

217 Posts

Posted - 2011-05-09 : 12:04:12
I am trying to select * from a table where a value is equal to 'Vacation' 'Holiday' 'ETO' or 'Sicktime' and I keep getting a syntax error. What's the best way to write this query?

I thought I could do

SELECT * from table where code = 'Vacation' or 'Holiday' or 'ETO' or 'Sicktime'

but that's not working.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-05-09 : 12:08:25
Eithere repeat code = 'vacation' or code = 'Holiday' etc
or better

where code IN ('Vacation','Holiday',etc.)

Jim

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

dougancil
Posting Yak Master

217 Posts

Posted - 2011-05-10 : 17:18:31
Thank you Jim. Thats what I needed.
Go to Top of Page
   

- Advertisement -