1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| with dataset (scores) as (
values
row ('[
{ "tr": "16", "tt": "40", "type": "t2a", "week": 45, "player" : "67" },
{ "tr": null, "tt": null, "type": "t2a", "week": 45, "player" : "71" },
{ "tr": null, "tt": null, "type": "t2a", "week": 45, "player" : "92" },
{ "tr": null, "tt": null, "type": "lf", "week": 45, "player" : "67" },
{ "tr": 12, "tt": 30, "type": "lf", "week": 45, "player" : "71" },
{ "tr": 20, "tt": 40, "type": "lf", "week": 45, "player" : "92" },
{ "tr": null, "tt": null, "type": "lf", "week": 45, "player" : "69" }
]'),
row ('[
{ "tr": "40", "tt": "50", "type": "t2a", "week": 46, "player" : "67" },
{ "tr": "35", "tt": "50", "type": "t2a", "week": 46, "player" : "71" },
{ "tr": "20", "tt": "40", "type": "t2a", "week": 46, "player" : "92" },
{ "tr": 9, "tt": 10, "type": "lf", "week": 46, "player" : "67" },
{ "tr": 8, "tt": 10, "type": "lf", "week": 46, "player" : "71" },
{ "tr": 19, "tt": 20, "type": "lf", "week": 46, "player" : "92" }
]')
)
select all scores.*, dataset.*
from dataset
cross join json_table(scores, '$[*]' columns (
tr tinyint unsigned path '$.tr',
tt tinyint unsigned path '$.tt',
type tinytext path '$.type',
week tinyint unsigned path '$.week',
player tinyint unsigned path '$.player'
)) as scores
where scores.player = 67; |
Partager