数据库
首页 > 数据库> > 关于mysql jsonarray 数据解析成新的行列

关于mysql jsonarray 数据解析成新的行列

作者:互联网

select id,name,json_unquote(json_extract(json_column,'$[',idx,']','.param1')) as param1,

json_unquote(json_extract(json_column,'$[',idx,']','.param2')) as param2

from test1

join 

(select 0 as idx union

select 1 as idx union

select 2 as idx union

select 3 as idx union

select 4 as idx union

select 5 as idx union

select 6 as idx union

select 7 as idx union

select 8

) as  test2

where json_extract(json_column,concat('$[',idx,']')) is not null ;

 

1.json_unquote:去掉json字符串中的双引号,

2.构造 test2,可以方便json_extract取值,思路很妙,Mark一下

 

标签:unquote,成新,idx,jsonarray,union,json,mysql,extract,select
来源: https://www.cnblogs.com/Pluto-0609/p/15467931.html