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)
 SELECTS using ANDs and ORs

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-08-08 : 08:44:25
Daniel writes "Hi:
I've a table with lots of multiple choice groups of bit fields. Im looking for an elegant way to make the following ILLEGAL query:

SELECT * WHERE (A=1 OR B=1 OR C=1) AND (D=1 OR E=1 OR F=1) AND (G=1 OR H=1 OR I=1)

Of course you could write the opposite way -- (A and D and G) OR (B and D and G) OR (C and D and G) -- but this would be really cumbersome.

It doesn't seem like this type of query would be THAT uncommon -- am I missing something here? Im surprised it doesnt come up more often in books and discussion groups.

Whats the best approach?

Im using Win2kSP1 and SQL2kSP1."
   

- Advertisement -