数据表
id uid info
1 1001 {"name":"周年庆","status":0,"addtime":"2017-10-10"}
2 1002 [ {"name":"周年庆","status":1,"addtime":"2017-10-11"},{"name":"特价促销","status":0,"addtime":"2017-10-12"}]
3 1003 [ {"name":"特价促销","status":1,"addtime":"2017-10-12"},{"name":"国庆促销","status":0,"addtime":"2017-09-28"}]
比如要按 info字段中的 name和status去匹配一条记录,用Json_Contains如何实现。
select * from t where JSON_CONTAINS(info->'$[*].name', '"周年庆"', '$') AND JSON_CONTAINS(info->'$[*].status', '"1"', '$')
这样的语法,是会匹配到3条记录的.但是期望的结果是id为2的这条记录被匹配到。