Last active
August 15, 2021 21:10
-
-
Save DominikStyp/d230be18efb73c6ab1e934f33022031c to your computer and use it in GitHub Desktop.
SQL: Selecting data from JSON_TABLE()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name | color | price | |
---|---|---|---|
Laptop | black | 11000.00 | |
Jeans | blue | NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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