当前位置:网站首页> mysql8.0JSON_CONTAINS的使用说明
mysql8.0JSON_CONTAINS的使用说明
2022-07-05 14:16:00 【1024问】
JSON_CONTAINS的使用
语法
案例
JSON_CONTAINS函数问题
结构如下
JSON_CONTAINS的使用语法JSON_CONTAINS(json_doc, val[, path])
案例select * from tb where info->'$.name' = '特价促销' or JSON_CONTAINS(info->'$[*].name', '"特价促销"', '$')
SET @json = '{"A": 0, "B": {"C": 1}, "D": 2}';SELECT JSON_CONTAINS(@json, '2', '$.A');+----------------------------------+| JSON_CONTAINS(@json, '2', '$.A') |+----------------------------------+| 0 |+----------------------------------+SELECT JSON_CONTAINS(@json, '2', '$.D');+----------------------------------+| JSON_CONTAINS(@json, '2', '$.D') |+----------------------------------+| 1 |+----------------------------------+SELECT JSON_CONTAINS(@json, '{"C": 1}', '$.A');+-----------------------------------------+| JSON_CONTAINS(@json, '{"C": 1}', '$.A') |+-----------------------------------------+| 0 |+-----------------------------------------+SELECT JSON_CONTAINS(@json, '{"C": 1}', '$.B');+-----------------------------------------+| JSON_CONTAINS(@json, '{"C": 1}', '$.B') |+-----------------------------------------+| 1 |+-----------------------------------------+
JSON_CONTAINS函数问题mysql 存的是[14,15]这种数据结构 查询的解决办法
结构如下学生类:
@Column(value = "subject_ids", type = MySqlTypeConstant.TEXT)@ColumnComment(value = "科目。可多选,格式如[1,2,3]")private List<Long> subjectIds;
数据库类型:text
mysql 存储类型: [14,15]
这个时候根据科目ID去查询有那些学生选择了14这个科目得时候就不能用in这个语法了
这个时候就可以使用
SELECT * FROM `t_student` where JSON_CONTAINS(subject_ids, '14')
以上为个人经验,希望能给大家一个参考,也希望大家多多支持软件开发网。
边栏推荐
- TiCDC 6.0原理之Sorter演进
- Sorter evolution of ticdc 6.0 principle
- Shenziyu, the new chairman of Meizu: Mr. Huang Zhang, the founder, will serve as the strategic adviser of Meizu's scientific and technological products
- Catch all asynchronous artifact completable future
- Why do mechanical engineers I know complain about low wages?
- 登录界面代码
- R语言dplyr包select函数、group_by函数、mutate函数、cumsum函数计算dataframe分组数据中指定数值变量的累加值、并生成累加数据列
- R Language ggplot2 Visualization: visualize linegraph, using Legend in Theme function. Paramètre de position emplacement de la légende personnalisée
- What is the ranking of GF futures? Is it safe and reliable to open an account for GF futures online?
- Thymeleaf 使用后台自定义工具类处理文本
猜你喜欢
Thymeleaf 模板的创建与使用
如何深入理解“有限状态机”的设计思想?
Make the seckill Carnival more leisurely: the database behind the promotion (Part 2)
物联网应用技术专业是属于什么类
家用电器行业商业供应链协同平台解决方案:供应链系统管理精益化,助推企业智造升级
软件测试人在深圳有哪些值得去的互联网公司【软件测试人员专供版】
Thymeleaf th:classappend attribute append th:styleappend style append th:data- custom attribute
魅族新任董事長沈子瑜:創始人黃章先生將作為魅族科技產品戰略顧問
TDengine 社区问题双周精选 | 第三期
Shenziyu, the new chairman of Meizu: Mr. Huang Zhang, the founder, will serve as the strategic adviser of Meizu's scientific and technological products
随机推荐
Webrtc learning (II)
Login interface code
家用电器行业商业供应链协同平台解决方案:供应链系统管理精益化,助推企业智造升级
Thymeleaf 常用函数
Mingfeng medical sprint technology innovation board: annual revenue of 350million yuan, proposed to raise 624million yuan
Hongmeng fourth training
R language ggplot2 visual density map: Visual density map by group and custom configuration geom_ The alpha parameter in the density function sets the image transparency (to prevent multiple density c
Postman简介、安装、入门使用方法详细攻略!
基于 TiDB 场景式技术架构过程 - 理论篇
Thymeleaf 使用后台自定义工具类处理文本
R语言ggplot2可视化条形图:通过双色渐变配色颜色主题可视化条形图、为每个条形添加标签文本(geom_text函数)
R语言ggplot2可视化密度图:按照分组可视化密度图、自定义配置geom_density函数中的alpha参数设置图像透明度(防止多条密度曲线互相遮挡)
04_ Use of solrj7.3 of solr7.3
C - Divisors of the Divisors of An Integer Gym - 102040C
物联网应用技术专业是属于什么类
R语言使用ggplot2包的geom_histogram函数可视化直方图(histogram plot)
Principle and performance analysis of lepton lossless compression
神经网络物联网未来发展趋势怎么样
What is the ranking of GF futures? Is it safe and reliable to open an account for GF futures online?
Don't be unconvinced. Mobile phone function upgrade is strong