tencent cloud

Feedback

Comparison Functions

Last updated: 2023-11-08 14:21:14
Comparison functions are described as follows:
Function
Description
value1 = value2
Returns TRUE if value1 is equal to value2 and FALSE otherwise.
Returns NULL if value1 or value2 is NULL. In WHERE conditions, NULL is treated as FALSE. Therefore, it is recommended to use IS NULL instead of = NULL when comparing a value with NULL.
The difference between = and IS NOT DISTINCT FROM lies in how they handle NULL values.
value1 <> value2
Returns TRUE if value1 is not equal to value2; otherwise FALSE.
value1 > value2
Returns TRUE if value1 is greater than value2; otherwise FALSE.
value1 >= value2
Returns TRUE if value1 is greater than or equal to value2; otherwise FALSE.
value1 < value2
Returns TRUE if value1 is less than value2; otherwise FALSE.
value1 <= value2
Returns TRUE if value1 is less than or equal to value2; otherwise FALSE.
value IS NULL
Returns TRUE if value is NULL; otherwise FALSE.
value IS NOT NULL
Returns TRUE if value is not NULL; otherwise FALSE.
value1 IS DISTINCT FROM value2
Returns TRUE if two values are different; otherwise FALSE. NULL values are treated as identical.
value1 IS NOT DISTINCT FROM value2
Returns TRUE if two values are equal; otherwise FALSE. NULL values are treated as identical.
value1 BETWEEN [ ASYMMETRIC | SYMMETRIC ] value2 AND value3
Returns TRUE if value1 is greater than or equal to value2 and less than or equal to value3; otherwise FALSE.

[ ] represents an optional parameter. The default value is ASYMMETRIC. When the SYMMETRIC keyword is explicitly declared, the values of value2 and value3 can be interchanged without affecting the result.
value1 NOT BETWEEN [ ASYMMETRIC | SYMMETRIC ] value2 AND value3
Returns TRUE if value1 is less than value2 or greater than value3; otherwise FALSE.

[ ] represents an optional parameter. The default value is ASYMMETRIC. When the SYMMETRIC keyword is explicitly declared, the values of value2 and value3 can be interchanged without affecting the result.
string1 LIKE string2
Returns TRUE if string1 matches pattern string2; otherwise FALSE.
string1 NOT LIKE string2
Returns TRUE if string1 does not match pattern string2; otherwise FALSE.
string1 SIMILAR TO string2
Returns TRUE if string1 matches regular expression string2; otherwise FALSE.
string1 NOT SIMILAR TO string2
Returns TRUE if string1 does not match regular expression string2; otherwise FALSE.
value IN (listItem [, listItem]* )
Returns TRUE if value exists in the given list. This statement is equivalent to connecting multiple OR expressions.
When the list contains NULL, returns NULL if value cannot be found and FALSE otherwise.
Always returns NULL if value is NULL.
value NOT IN (listItem, [, listItem]*)
Returns TRUE if value does not exist in the given list; otherwise FALSE.
EXISTS (sub-query)
Returns TRUE if sub-query returns at least one row; otherwise FALSE.
This query can cause memory pressure.
value IN (sub-query)
Returns TRUE if value is equal to a row returned by sub-query.
This query can cause memory pressure.
value NOT IN (sub-query)
Returns TRUE if value is not equal to a row returned by sub-query.
This query can cause memory pressure.

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support