1.获取指定json字符串中指定的属性值,以下三种写法等价:
json_extract(attributes_json,‘$.DP‘) //json_extract()方法获取json中指定的值,格式:json_extract(json_field,‘$.DP‘)
attributes_json->‘$.DP‘ //attributes_json字段的值为一个json字符串,下面的语句都是获取attributes_json中的DP属性的值
attributes_json->>‘$.DP‘ //可以有两个尖括号
2.去掉查询结果中首尾的双引号:
json_unquote()
SELECT json_unquote(json_extract (tea.`teacher_class_type`,‘$[0].Id‘)) FROM tb_teacher tea WHERE tea.`biz_id` = ‘00000000b162333ff‘
还可以以下方式:
REPLACE去除结果中的双引号
SELECT REPLACE(tea.`teach_id` -> ‘$[0].id‘,‘"‘,‘‘) AS ‘sch‘ FROM tb_teacher tea
原文:https://www.cnblogs.com/87060524test/p/11612633.html