add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table t(id int not null primary key, epos int, array json)
insert into t values
(1, 2, json_array(2, 4)),
(2, 3, json_array(10)),
(3, 1, json_array(2, 3, 4)),
(4, 4, json_array(10, 11))
select t.id, t.epos, cast(t.array as char) as tostring, jt.*
from t
cross join json_table(t.array, '$[*]' columns(i for ordinality, v int path '$')) as jt
order by t.id, jt.i
id epos tostring i v
1 2 [2, 4] 1 2
1 2 [2, 4] 2 4
2 3 [10] 1 10
3 1 [2, 3, 4] 1 2
3 1 [2, 3, 4] 2 3
3 1 [2, 3, 4] 3 4
4 4 [10, 11] 1 10
4 4 [10, 11] 2 11
select id, epos, cast(array as char) as tostring, (
select group_concat(lpad(jt.v, 8, '0') order by jt.i)
from json_table(t.array, '$[*]' columns(i for ordinality, v int path '$')) as jt
) as sort_str
from t
order by sort_str
id epos tostring sort_str
3 1 [2, 3, 4] 00000002,00000003,00000004
1 2 [2, 4] 00000002,00000004
2 3 [10] 00000010
4 4 [10, 11] 00000010,00000011