Condividi tramite


<=> Operatore (lt eq gt sign)

Si applica a:segno di spunta sì Databricks SQL segno di spunta sì Databricks Runtime

Restituisce lo stesso risultato di EQUAL(=) per gli operandi non Null, ma restituisce true se entrambi sono NULL, false se uno di essi è NULL. Questo operatore è un sinonimo di expr1 is not distinct from expr2.

Sintassi

expr1 <=> expr2

Argomenti

  • expr1: espressione di un tipo paragonabile.
  • expr2: espressione che condivide un tipo meno comune con expr1.

Valori restituiti

Valore booleano.

Esempi

> SELECT 2 <=> 2;
 true
> SELECT 1 <=> '1';
 true
> SELECT true <=> NULL;
 false
> SELECT NULL <=> NULL;
 true

-- By default string comparisons are trailing space 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

 -- String comparisons are trailing space sensitive by default
-- Use the COLLATE clause to override the default
> 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