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
 General SQL Server Forums
 New to SQL Server Programming
 A quick question about filtering multiple items

Author  Topic 

mandyliftmeup
Starting Member

2 Posts

Posted - 2010-10-08 : 00:47:28
I'm trying to query something out that requires filtering by numerous WHERE NAME = A... essentially over 100 different criteria. Is there an easier way of doing this than typing them in individually?

For example, can I bracket criterion like:

WHERE NAME = (A, B, C)?

Or is there another way?

Or do I actually have to type everything in like:

WHERE NAME = A OR NAME = B OR NAME = C.... etc. ?

Thanks!

Sachin.Nand

2937 Posts

Posted - 2010-10-08 : 00:59:20
WHERE NAME IN (A, B, C, D....100 criteria's).

PBUH

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-08 : 01:15:23
Are the values stored in a table? Can you use a JOIN using some criteria that distinguishes the ones you want?

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

Subscribe to my blog
Go to Top of Page

mandyliftmeup
Starting Member

2 Posts

Posted - 2010-10-08 : 01:20:15
Thanks Guys! Didn't expect such fast responses. WHERE ___ IN worked beautifully. Tara, I'll keep that in mind for the future. I know it'll come in handy. I've always been an Excel guy so using databases to pull data is new to me. But thanks again for the tips!
Go to Top of Page
   

- Advertisement -