现有如下需求,找出mysql 某个字段(json类型)中是否存在某个值:

可以使用 where json_search() is not null ,如以下语句
$sql = "SELECT * FROM `fare_template_detail` WHERE json_search(area,'one','75') is not null and template_id = 1 ";
或者
$sql = "SELECT * FROM `fare_template_detail` WHERE json_search(area,'one','%75%') is not null and template_id = 1 ";
以及延伸到json字段中的某个key中查找
$sql = "SELECT * FROM `fare_template_detail` WHERE json_search(area,'one','75',null,"$[0]") is not null and template_id = 1 ";
如 json 中存在key,则是用点
"SELECT * FROM `fare_template_detail` WHERE json_search(area,'one','75',null,'$.list') is not null and template_id = 1";
