数据库
首页 > 数据库> > Mysql读取JSON字符串

Mysql读取JSON字符串

作者:互联网

 

将Name字段JSON解析出来

 

SELECT
ID,
JSON_EXTRACT(`Name`,'$.Name') AS `Name`,
JSON_EXTRACT(`Name`,'$.Age') AS Age,
JSON_EXTRACT(`Name`,'$.Sex') AS Sex
FROM test

 

结果展示:

 

去掉双引号

SELECT
ID,
JSON_UNQUOTE(JSON_EXTRACT(`Name`,'$.Name')) AS `Name`,
JSON_UNQUOTE(JSON_EXTRACT(`Name`,'$.Age')) AS Age,
JSON_UNQUOTE(JSON_EXTRACT(`Name`,'$.Sex')) AS Sex
FROM test

 

 

 

 

 

 

备注:Mysql5.7 以后版本支持JSON读取

 

标签:UNQUOTE,Name,Age,Sex,JSON,Mysql,EXTRACT,读取
来源: https://www.cnblogs.com/liu-blog/p/16700064.html