问题
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?
来源:https://stackoverflow.com/questions/39508478/get-distinct-values-from-mysql-json-array