当前位置:网站首页> 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')
以上为个人经验,希望能给大家一个参考,也希望大家多多支持软件开发网。
边栏推荐
- Sharing the 12 most commonly used regular expressions can solve most of your problems
- 日化用品行业智能供应链协同系统解决方案:数智化SCM供应链,为企业转型“加速度”
- How to introduce devsecops into enterprises?
- Fault analysis | analysis of an example of MySQL running out of host memory
- CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
- 做自媒體視頻二次剪輯,怎樣剪輯不算侵權
- Mysql database installation tutorial under Linux
- VC development of non MFC program memory leak tracking code
- 神经网络物联网未来发展趋势怎么样
- TiFlash 面向编译器的自动向量化加速
猜你喜欢
Loop invariant
软件测试人在深圳有哪些值得去的互联网公司【软件测试人员专供版】
ASP.NET大型外卖订餐系统源码 (PC版+手机版+商户版)
Sorter evolution of ticdc 6.0 principle
Lepton 无损压缩原理及性能分析
TDengine 社区问题双周精选 | 第三期
TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
What is the future development trend of neural network Internet of things
Thymeleaf th:classappend attribute append th:styleappend style append th:data- custom attribute
随机推荐
SAS接口有什么优势特点
Sharing the 12 most commonly used regular expressions can solve most of your problems
R语言ggplot2可视化条形图:通过双色渐变配色颜色主题可视化条形图、为每个条形添加标签文本(geom_text函数)
Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 2)
TiFlash 面向编译器的自动向量化加速
Time to calculate cron expression based on cronsequencegenerator
Linux下mysql数据库安装教程
Assembly language
[buuctf.reverse] 152-154
Oneconnect listed in Hong Kong: with a market value of HK $6.3 billion, ye Wangchun said that he was honest and trustworthy, and long-term success
动态规划
魅族新任董事长沈子瑜:创始人黄章先生将作为魅族科技产品战略顾问
【学习笔记】阶段测试1
SSH免密码登录详解
故障分析 | MySQL 耗尽主机内存一例分析
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
03_ Dataimport of Solr
Why do mechanical engineers I know complain about low wages?
Use the word "new" to attract curious people
汇编语言 assembly language