How can I pick only the non matching elements between two arrays.
Example:
base_array [12,3,5,7,8]
temp_array [3,7,8]
So here I wan
I've constructed a set of functions to deal specifically with these types of issues: https://github.com/JDBurnZ/anyarray
The greatest thing is these functions work across ALL data-types, not JUST integers, as intarray is limited to.
After loading loading the functions defined in those SQL files from GitHub, all you'd need to do is:
SELECT
ANYARRAY_DIFF(
ARRAY[12, 3, 5, 7, 8],
ARRAY[3, 7, 8]
)
Returns something similar to: ARRAY[12, 5]
If you also need to return the values sorted:
SELECT
ANYARRAY_SORT(
ANYARRAY_DIFF(
ARRAY[12, 3, 5, 7, 8],
ARRAY[3, 7, 8]
)
)
Returns exactly: ARRAY[5, 12]