- Categories:
[ NOT ] EQUAL_NULL¶
Compares whether two expressions are equal. The function is NULL-safe, meaning it treats NULLs as known values for comparing equality. Note that this is different from the EQUAL
comparison operator (=), which treats NULLs as unknown values.
- See also:
Syntax¶
Usage notes¶
The value returned depends on whether any of the inputs are NULL values:
- Returns TRUE:
EQUAL_NULL( <null> , <null> )- Returns FALSE:
EQUAL_NULL( <null> , <not_null> )EQUAL_NULL( <not_null> , <null> )
Otherwise:
EQUAL_NULL(<expr1>, <expr2>)is equivalent to<expr1> = <expr2>
For more details, see the examples below.
Collation details¶
The collation specifications of all input arguments must be compatible.
The comparisons follow the collation based on the input arguments’ collations and precedences.
Examples¶
Create a table with simple data:
Show the Cartesian product generated by joining the table to itself without a filter:
Return rows that contain only equal values for both columns:
Return rows that contain only equal values or NULL values for both columns:
Illustrate all possible outcomes for EQUAL (=) and NOT EQUAL (<>):
Illustrate all possible outcomes for EQUAL_NULL and NOT EQUAL_NULL: