Partager via


<=> Opérateur = (signe inférieur égal supérieur)

S’applique à :case marquée oui Databricks SQL case marquée oui Databricks Runtime

Retourne le même résultat que EQUAL(=) pour les opérandes non Null, mais true si les deux sont NULL et false si l’un d’eux est NULL. Cet opérateur est un synonyme de l'expr1 is not distinct from expr2.

Syntaxe

expr1 <=> expr2

Arguments

  • expr1 : expression d’un type comparable.
  • expr2 : expression qui partage un type le moins commun avec expr1.

Retours

Une valeur BOOLÉENNE.

Exemples

> 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