📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

ARRAY_OVERLAP



Checks if there is any overlap between two JSON arrays and returns true if there are common elements; otherwise, it returns false.

Aliases

  • JSON_ARRAY_OVERLAP

Syntax

ARRAY_OVERLAP(<json_array1>, <json_array2>)

Return Type

The function returns a boolean value:

  • true if there is at least one common element between the two JSON arrays,
  • false if there are no common elements.

Examples

SELECT ARRAY_OVERLAP( '["apple", "banana", "cherry"]'::JSON, '["banana", "kiwi", "mango"]'::JSON ); -[ RECORD 1 ]----------------------------------- array_overlap('["apple", "banana", "cherry"]'::VARIANT, '["banana", "kiwi", "mango"]'::VARIANT): true SELECT ARRAY_OVERLAP( '["grape", "orange"]'::JSON, '["apple", "kiwi"]'::JSON ); -[ RECORD 1 ]----------------------------------- array_overlap('["grape", "orange"]'::VARIANT, '["apple", "kiwi"]'::VARIANT): false

Was this page helpful?