JSON_CONTAINS对brand字段的查询
SELECT name,brand from table1 WHERE
JSON_CONTAINS(brand->'$[*]."category"', JSON_ARRAY('巧克力'))
or JSON_CONTAINS(brand->'$[*]."category"', JSON_ARRAY('饮料'))
brand的json结构如下
[{
"name": "随便一个name",
"brand": "娃哈哈",
"id": "222222",
"category": "饮料"
}]
JSON_EXTRACT对key的查询大小比较
SELECT points from table2 where
JSON_EXTRACT(points,'$."10"') > "231"
and JSON_EXTRACT(points,'$."10"') < "500"
points的json结构如下,key是积分id,value对于积分值
{
"11": "600",
"12": "400",
"18": "1052",
"20": "6"
}