colleagues. I have a table like this:
id | param1 | param2 | config |
---|---|---|---|
123 | 456 | 789 | {"confToUse": "b", "configs": {"a": { "qwe": "rty" }, "b": { "asd", "fgh" } } } |
Small explanation: configurations live in a json 'dictionary' property configs
, configToUse
property points on config with this key to use.
My goal is to get new table where each row is a separate configuration:
id | name | config |
---|---|---|
x_uniq | a | { "qwe": "rty" } |
y_uniq | b | { "asd", "fgh" } |
Ideally the result looks like this:
id | param1 | param2 | use | name | config | use_id |
---|---|---|---|---|---|---|
x_uniq | 456 | 789 | b | a | { "qwe": "rty" } |
y_uniq? |
y_uniq | 456 | 789 | b | b | { "asd", "fgh" } |
y_uniq? |
For mysql version reason I can't use JSON_TABBLE. Only JSON_EXTRACT or so.
At this point could only do this:
SELECT
JSON_EXTRACT(tbl.config, "$.configToUse"),
JSON_EXTRACT(tbl.config, "$.configs") -- I think there has to be some SELECT
FROM
configs_table tbl
WHERE
tbl.id = 123
;
and get:
xxx | yyy |
---|---|
b | {"a": { "qwe": "rty" }, "b": { "asd", "fgh" } } |
Please, give me some way to move.