Simple Expressions
Logical Expressions
Logical Operators lists the operators and calculation rules of logical expressions.
Comparison Expressions
Comparison Functions and Comparison Operators lists the common comparison operators.
In addition to comparison operators, you can also use the following sentence structures:
a BETWEEN x AND y
Generally, it is equivalent to a ≥ x AND a ≤ y.
a NOT BETWEEN x AND y
Generally, it is equivalent to a < x OR a > y.
- During conversion, the BETWEEN operator first determines the comparison type for a and x, and then determines the final comparison type based on the comparison type for a and x as well as y. Therefore, the result is not equivalent to that of a >= x AND a <= y in complex scenarios.
- In a BETWEEN x AND y, x and y cannot use expressions, for example, 1 < 1.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
m_db=# SELECT 2 BETWEEN 1 AND 3 AS RESULT; result ---------- t (1 row) m_db=# SELECT 2 >= 1 AND 2 <= 3 AS RESULT; result ---------- t (1 row) m_db=# SELECT 2 NOT BETWEEN 1 AND 3 AS RESULT; result ---------- f (1 row) m_db=# SELECT 2 < 1 OR 2 > 3 AS RESULT; result ---------- f (1 row) m_db=# SELECT '2' between 'a' AND 3.0 AS RESULT; WARNING: Truncated incorrect double value: 'a' CONTEXT: referenced column: RESULT result ---------- t (1 row) m_db=# SELECT '2' >= 'a' AND '2' <= 3.0 AS RESULT; result ---------- f (1 row) |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot