Sorry for necromancing, but I've encountered similar issue. The solution is: JSON_TABLE() available since MySQL 8.0.
First, merge the arrays in rows into one-row single array.
select concat('[', -- start wrapping single array with opening bracket
replace(
replace(
group_concat(vals), -- group_concat arrays from rows
']', ''), -- remove their opening brackets
'[', ''), -- remove their closing brackets
']') as json -- finish wraping single array with closing bracket
from (
select '[801, 751, 603, 753, 803]' as vals
union select '[801, 751]'
union select '[578, 66, 15]'
) as jsons;
# gives: [801, 751, 603, 753, 803, 801, 751, 578, 66, 15]
Second, use json_table to convert the array into rows.
select val
from (
select concat('[',
replace(
replace(
group_concat(vals),
']', ''),
'[', ''),
']') as json
from (
select '[801, 751, 603, 753, 803]' as vals
union select '[801, 751]'
union select '[578, 66, 15]'
) as jsons
) as merged
join json_table(
merged.json,
'$[*]' columns (val int path '$')
) as jt
group by val;
# gives...
801
751
603
753
803
578
66
15
See https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html#function_json-table
Notice group by val for getting distinct values. You can also order them and everything...
Or you can use group_concat(distinct val) without the group by directive (!) to get one-line result.
Or even cast(concat('[', group_concat(distinct val), ']') as json) to get a proper json array: [15, 66, 578, 603, 751, 753, 801, 803].
Read my Best Practices for using MySQL as JSON storage :)