Skip to content

Instantly share code, notes, and snippets.

@DominikStyp
Last active August 15, 2021 21:10
Show Gist options
  • Save DominikStyp/d230be18efb73c6ab1e934f33022031c to your computer and use it in GitHub Desktop.
Save DominikStyp/d230be18efb73c6ab1e934f33022031c to your computer and use it in GitHub Desktop.
SQL: Selecting data from JSON_TABLE()
name color price
Laptop black 11000.00
Jeans blue NULL
USE test;
set @json='
[
{"name":"Laptop", "color":"black", "price":"1000"},
{"name":"Jeans", "color":"blue"}
]';
select * from json_table(@json, '$[*]'
columns(
name varchar(10) path '$.name',
color varchar(10) path '$.color',
price decimal(8,2) path '$.price' )
) as jt;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment