Compartir a través de


<=>Operador (signo menor que, igual que o mayor que)

Se aplica a:casilla marcada como Sí Databricks SQL casilla marcada como Sí Databricks Runtime

Devuelve el mismo resultado que EQUAL(=) para los operandos que no son NULL, pero devuelve true si los dos son NULL, o bien false si uno de ellos es NULL. Este operador es un sinónimo de expr1 is not distinct from expr2.

Sintaxis

expr1 <=> expr2

Argumentos

  • expr1: expresión de un tipo comparable.
  • expr2: una expresión que comparte un tipo menos común con expr1.

Devoluciones

Una expresión BOOLEANA.

Ejemplos

> 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