I want to extract JSON object data (Key/value) as multiple column/value in MySQL.
Let say I have following data:
CREATE TABLE t3 (id INT, jdoc JSON);
INSERT INTO t3 VALUES
(1, '{"groups": {"CS":15, "Physics":20,"Chemistry":10}}'),
(2, '{"groups": {"CS":6, "Physics":8,"Chemistry":5}}');
Is there anyway that above data can be extracted as following output. e.g. Key Name as column name and values as row.
id| CS | Physics | Chemistry
1 | 15 | 20 | 10
2 | 6 | 8 | 5
Please note, I can change the jdoc's JSON data format in order to get required output.