arrays_overlap

arrays_overlap

description

Syntax

BOOLEAN arrays_overlap(ARRAY<T> left, ARRAY<T> right)

Check if there is any common element for left and right array. Return below values:

  1. 1 - if any common element inside left and right array;
  2. 0 - if no common element inside left and right array;
  3. NULL - when left or right array is NULL; OR any element inside left and right array is NULL;

example

  1. mysql> select c_left,c_right,arrays_overlap(c_left,c_right) from array_test;
  2. +--------------+-----------+-------------------------------------+
  3. | c_left | c_right | arrays_overlap(`c_left`, `c_right`) |
  4. +--------------+-----------+-------------------------------------+
  5. | [1, 2, 3] | [3, 4, 5] | 1 |
  6. | [1, 2, 3] | [5, 6] | 0 |
  7. | [1, 2, NULL] | [1] | NULL |
  8. | NULL | [1, 2] | NULL |
  9. | [1, 2, 3] | [1, 2] | 1 |
  10. +--------------+-----------+-------------------------------------+

keywords

ARRAY,ARRAYS,OVERLAP,ARRAYS_OVERLAP