Skip to main content

== (eq eq sign) operator

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Returns true if expr1 equals expr2, or false otherwise. This function is a synonym for = (eq sign) operator. Use equal_null to treat NULL as a comparable value.

Syntax

expr1 == expr2

Arguments

  • expr1: An expression of any comparable type.
  • expr2: An expression sharing a least common type with expr1.

Returns

A BOOLEAN.

Examples

SQL
> SELECT 2 == 2;
true

> SELECT 1 == '1';
true

> SELECT true == NULL;
NULL

> SELECT NULL == NULL;
NULL

-- By default string comparisons are trailing blank sensitive
-- This can be overridden by using the COLLATE clause
> SELECT 'hello' == 'hello ' AS default,
'hello' == 'hello ' COLLATE UTF8_BINARY AS utf8_binary,
'hello' == 'hello ' COLLATE UTF8_BINARY_RTRIM AS rtrim;
default utf8_binary rtrim
------- ----------- -----
false false true

-- By default string comparisons are trailing space sensitive
-- This can be overridden by using the COLLATE clause
> SELECT 'world ' == 'world ' AS default,
'world ' == 'world ' COLLATE UTF8_BINARY AS utf8_binary,
'world ' == 'world ' COLLATE UTF8_BINARY_RTRIM AS rtrim;
default utf8_binary rtrim
------- ----------- -----
false false true