Tomato
Tomato

Reputation: 9

Base WHERE statement with many OR statements

(insert typical I'm a noob comment and a million apologies for asking a noob question)

I'm trying to simplify a query where I'm trimming a set of data. I've created a WHERE statement from all the other OR statements to be based off of. The issue I'm having now is not repeating the base WHERE statement for each OR condition.

What I'm having to do:

WHERE ((base conditions) AND X) OR 
((base conditions) AND Y) OR
ETC.....

What I want to do

WHERE ((base conditions) OR X OR Y)

I'm thinking I can set up the base conditions and then query the base condition with OR statements but I don't know if that's what I'm suppose to do.

Thanks in advance!

Upvotes: 0

Views: 46

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269843

Of course you can do that. You just need parentheses:

WHERE (base conditions) AND
      (X OR Y OR Z . . .)

Upvotes: 1

Related Questions