0

This is a simple question but I'm getting stuck on it. Basically I need to add in the following AND statements to a query:

AND  a.d_max > '0' AND  a.max > '0'

BUT I would also like to make it so the max is either greater than 0 or = u because if it's set to u it means unlimited. So something like:

AND  a.d_max > '0' OR a.d_max = u AND  a.max > '0' OR a.max = u

How would I go about doing this?

1
  • Is u a field name or a constant? Note, that you may actually want to use > 0, not > '0' because = 'u' is also > '0'. Commented Mar 12, 2013 at 17:13

2 Answers 2

2

I think your logic is ok, but you're just missing some parentheses:

AND
  (a.d_max > '0' OR a.d_max = u) AND (a.max > '0' OR a.max = u)
Sign up to request clarification or add additional context in comments.

Comments

0

You can prioritize the evaluation of expressions/conditions using paranthesis:

In you case, I think you need this :

AND  (a.d_max > '0' OR a.d_max = u) AND  (a.max > '0' OR a.max = u)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.