mysql遍历json数组,从MySQL JSON数组获取不同的值

I got a MySQL data Table, with a JSON Column containing a list of Values:

CONSTRAINT_TABLE

ID | CONSTRAINT_TYPE | CONSTRAINT_VALUES

----+-----------------+--------------------------------

'2'| 'testtype' |'[801, 751, 603, 753, 803]'

...| ... | ...

What I want to have is a distinct, comma-seperated List of JSON-Values. I tried it with group_concat, but it applys to the arrays, not the single values.

SELECT group_concat(distinct constraint_values->>'$')

FROM constraint_table c

WHERE c.constraint_type = "testtype";

Actual result:

[801, 751, 603, 753, 803],[801, 751],[578, 66, 15],...

My target result:

801, 751, 603, 753, 803, 578, 66, 15 ...

without duplicates. As rows would be nice, too.

Ideas, anyone?

解决方案

你可能感兴趣的:(mysql遍历json数组)