Aller au contenu

Vérifie si deux tableaux JSON ont des éléments en commun et renvoie true si c’est le cas, sinon false.

JSON_ARRAY_OVERLAP(<json_array1>, <json_array2>)

La fonction renvoie une valeur booléenne :

  • true s’il existe au moins un élément commun aux deux tableaux JSON,
  • false s’il n’existe aucun élément commun.
SELECT json_array_overlap(
'["apple", "banana", "cherry"]'::JSON,
'["banana", "kiwi", "mango"]'::JSON
);
-[ RECORD 1 ]-----------------------------------
json_array_overlap('["apple", "banana", "cherry"]'::VARIANT, '["banana", "kiwi", "mango"]'::VARIANT): true
SELECT json_array_overlap(
'["grape", "orange"]'::JSON,
'["apple", "kiwi"]'::JSON
);
-[ RECORD 1 ]-----------------------------------
json_array_overlap('["grape", "orange"]'::VARIANT, '["apple", "kiwi"]'::VARIANT): false