示例:{ “key”: “value” }
一、json是什么?一种轻量级的数据交换格式是json(javascript object notation)。json采用完全独立于语言的文本格式,这些特性使json成为理想的数据交换语言。易于人阅读和编写,同时也易于机器解析和生成。
二、不同情况1.模糊查询json类型字段存储的数据格式(字段名 people_json):
{“name”: “zhangsan”, “age”: “13”, “gender”: “男”}
代码如下(示例):
select * from table_name where people_json->'$.name' like '%zhang%'
2.精确查询json类型字段存储的数据格式(字段名 people_json):
{“name”: “zhangsan”, “age”: “13”, “gender”: “男”}
代码如下(示例):
select * from table_name where people_json-> '$.age' = 13
3.模糊查询jsonarray类型字段存储的数据格式(字段名 people_json):
[{“name”: “zhangsan”, “age”: “13”, “gender”: “男”}]
代码如下(示例):
select * from table_name where people_json->'$[*].name' like '%zhang%'
4.精确查询jsonarray类型字段存储的数据格式(字段名 people_json):
[{“name”: “zhangsan”, “age”: “13”, “gender”: “男”}]
代码如下(示例):
select * from table_name where json_contains(people_json,json_object('age', "13"))
以上就是mysql内储存json字符串实例分析的详细内容。
