AnalyticDB for PostgreSQL is compatible with the comparison functions and operators of PostgreSQL. This topic describes the comparison functions and operators that are supported by AnalyticDB for PostgreSQL and provides examples on how to use the comparison functions and operators.
For information about the comparison functions and operators of PostgreSQL, see Comparison Functions and Operators.
Comparison operators
Overview
Comparison operators are specific symbols that are used for comparison, such as =, !=, <, >, <=, and >=. Comparison operators can be applied to expressions. A comparison operator compares two values and returns a Boolean value of TRUE or FALSE to indicate the comparison result.
Usage
Comparison operators can be used in conditional statements (such as IF conditions), loop control, and SQL queries to determine how data is processed during filtering and sorting.
Operators
Comparison operators
Operator | Description |
| Less than |
| Greater than |
| Less than or equal to |
| Greater than or equal to |
| Equal to |
| Not equal to |
Comparison predicates
Comparison predicates function similarly to operators but must meet specific syntax requirements of the SQL standard.
Predicate | Description |
| Checks whether a is between |
| Checks whether a is not between |
| Checks whether a is between |
| Checks whether a is not between |
| Checks whether a and b are different. This predicate treats a NULL value as an ordinary value. |
| Checks whether a and b are identical. This predicate treats a NULL value as an ordinary value. |
| Checks whether an expression is NULL. |
| Checks whether an expression is not NULL. |
| Checks whether an expression is NULL. This predicate uses a non-standard syntax. |
| Checks whether an expression is not NULL. This predicate uses a non-standard syntax. |
| Checks whether a Boolean expression is TRUE. |
| Checks whether a Boolean expression is not TRUE (FALSE or UNKNOWN). |
| Checks whether a Boolean expression is FALSE. |
| Checks whether a Boolean expression is not FALSE (TRUE or UNKNOWN). |
| Checks whether a Boolean expression is UNKNOWN. |
| Checks whether a Boolean expression is not UNKNOWN (TRUE or FALSE). |
Comparison functions
Overview
Comparison functions are used to compare field values. For example, you can use the strcmp() function to compare strings or customize comparison functions. Comparison functions allow you to specify multiple parameters and custom comparison logic in a more flexible manner.
Usage
Comparison functions are useful in scenarios that involve complex comparison logic, such as performing case-insensitive string comparisons, comparing specific attributes of objects, and customizing sorting rules.
Functions
Function | Description | Example | Sample result |
| Returns the number of non-NULL arguments. |
|
|
| Returns the number of NULL arguments. |
|
|