user3258383
user3258383

Reputation: 39

Combining Two Where Statements

I am having difficulties combining the two statements below. I need my query to look for statement 1 OR statement 2. I can't figure out how to add an OR statement between the two. #Standard-SQL

Statement 1

WHERE
   (feedback IS NOT NULL OR text IS NOT NULL)
   AND rating <= 2

Statement 2

WHERE
   (rating = 3 OR rating = 4)
   AND feedback IS NOT NULL

Ideal Result is something like this...

WHERE
   (feedback IS NOT NULL OR text IS NOT NULL)
   AND rating <= 2
 OR  
   (rating = 3 OR rating = 4)
   AND feedback IS NOT NULL

Upvotes: 0

Views: 4634

Answers (1)

JNevill
JNevill

Reputation: 50034

Encapsulate both FULL conditions in parentheses:

WHERE
 (
   (feedback IS NOT NULL OR text IS NOT NULL)
   AND rating <= 2
 )
 OR 
 ( 
   (rating = 3 OR rating = 4)
   AND feedback IS NOT NULL
 )

Upvotes: 2

Related Questions