码迷,mamicode.com
首页 > 数据库 > 详细

SQL,JSON查询-

时间:2019-08-23 19:24:29      阅读:538      评论:0      收藏:0      [点我收藏+]

标签:pos   code   efi   add   http   rac   技术   inf   fine   

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[ , ‘$‘ ) ]]>

SQL,JSON查询-

标签:pos   code   efi   add   http   rac   技术   inf   fine   

原文地址:https://www.cnblogs.com/-levi/p/11401824.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!