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''"特价促销"''$')

 

查询语句:SELECT * FROM nlu_define_table WHERE JSON_CONTAINS(JSON_ARRAY("我","想","销","存单"),keywords->'$.keywords') ORDER BY weights DESC;

其他查询语句:

SELECT * FROM nlu_define_table;

SELECT * FROM nlu_define_table WHERE keywords LIKE "%销%";

SELECT * FROM nlu_define_table WHERE JSON_EXTRACT(keywords,'$.keywords') LIKE "%销%";

SELECT * FROM nlu_define_table WHERE keywords -> '$.keywords' LIKE "%销%";

第三条sql和第四条sql是等效。

 

MyBatis

select
    *
from nlu_define_table
where 1 = 1

AND
<![CDATA[ JSON_CONTAINS( info->'$[*].name', ]]> &apos;&quot;${name}&quot;&apos; <![CDATA[ , '$' ) ]]>

 

GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e 4 个月前
8c391e04 6 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐