Good guys I have a table in which a field is json in the following format:
{
"monday": [{"end": "18:00:00", "start": "09:00:00"}, {"end": "21:00:00", "start": "19:00:01"}],
"sunday": [{"end": "15:00:00", "start": "14:00:00"}],
"saturday": [{"end": "18:00:00", "start": "09:00:00"}]
}
I want know if is it possible to return all keys with their array items in a SELECT query, like this:
day | date_start | date_end |
---|---|---|
monday | 09:00:00 | 18:00:00 |
monday | 19:00:01 | 21:00:00 |
sunday | 14:00:00 | 15:00:00 |
saturday | 09:00:00 | 18:00:00 |
I tried this way:
SELECT j.*
FROM tabela t
INNER JOIN JSON_TABLE(
t.field_json,
'$.*[*]'
COLUMNS(
`date_start` TIME PATH '$.start',
`date_end` TIME PATH '$.end',
`day` VARCHAR(10) PATH '$.*'
)
) AS j
WHERE t.id=100
But the result is not what I want:
day | date_start | date_end |
---|---|---|
NULL | 09:00:00 | 18:00:00 |
NULL | 19:00:01 | 21:00:00 |
NULL | 14:00:00 | 15:00:00 |
NULL | 09:00:00 | 18:00:00 |
DB: https://dbfiddle.uk/9rXd_VL2
Any sugestion?