mysql json数组取值、查询

来源于网络,未验证。

数据表

id uid info
1 1001 {"name":"周年庆","status":0,"addtime":"2017-10-10"}
2 1002 [ {"name":"周年庆","status":0,"addtime":"2017-10-11"},{"name":"特价促销","status":0,"addtime":"2017-10-12"}]
3 1003 [ {"name":"特价促销","status":0,"addtime":"2017-10-12"},{"name":"国庆促销","status":0,"addtime":"2017-09-28"}]

取“特价促销”的用户数据

select * from tb
where info->'$.name' = '特价促销'  or JSON_CONTAINS(info->'$[*].name', '"特价促销"', '$')

 

转载于:https://www.cnblogs.com/xiede/p/9127606.html

你可能感兴趣的:(mysql json数组取值、查询)