解析sql查询的字段为json的字符串

时间:2024-03-29 12:49:42

SQL解析Json字符串


解析sql查询的字段为json的字符串

1. select content from message_record; 查询的结果类型如下,目的是想要提取下面json字符串中的数据。例如:提取的属性为serilalId。
解析sql查询的字段为json的字符串2.查询语句:select json_extract(content, '$.serialId') as serialId from message_record;
原函数:JSON_EXTRACT(json_doc, path[, path] ...)
查询结果如下图
解析sql查询的字段为json的字符串

①content:要查询的表的字段
②’$.serialId’:查询的json字段中的属性,注意加单引号

转载请标明地址