当前位置:网站首页> 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')
以上为个人经验,希望能给大家一个参考,也希望大家多多支持软件开发网。
边栏推荐
- 物联网应用技术专业是属于什么类
- R语言ggplot2可视化条形图:通过双色渐变配色颜色主题可视化条形图、为每个条形添加标签文本(geom_text函数)
- 03_Solr之dataimport
- What is the ranking of GF futures? Is it safe and reliable to open an account for GF futures online?
- TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析
- MySQL user-defined function ID number to age (supports 15 / 18 digit ID card)
- R语言使用原生包(基础导入包、graphics)中的boxplot函数可视化箱图(box plot)
- PMP考试20天能通过吗?
- 循环不变式
- 魅族新任董事長沈子瑜:創始人黃章先生將作為魅族科技產品戰略顧問
猜你喜欢
LeetCode_ 2 (add two numbers)
Tiflash compiler oriented automatic vectorization acceleration
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
Thymeleaf th:with use of local variables
Shen Ziyu, nouveau Président de Meizu: M. Huang Zhang, fondateur de Meizu, agira comme conseiller stratégique pour les produits scientifiques et technologiques de Meizu
世界环境日 | 周大福用心服务推动减碳环保
Why do mechanical engineers I know complain about low wages?
分享 12 个最常用的正则表达式,能解决你大部分问题
SAS接口有什么优势特点
随机推荐
openGauss数据库源码解析系列文章—— 密态等值查询技术详解(下)
LeetCode_ 67 (binary sum)
freesurfer运行完recon-all怎么快速查看有没有报错?——核心命令tail重定向
Current situation, trend and view of neural network Internet of things in the future
How to deeply understand the design idea of "finite state machine"?
How to protect user privacy without password authentication?
How to make a second clip of our media video without infringement
判断变量是否为数组
做自媒體視頻二次剪輯,怎樣剪輯不算侵權
汇编语言 assembly language
Mysql database installation tutorial under Linux
Linux下mysql数据库安装教程
Loop invariant
Time to calculate cron expression based on cronsequencegenerator
LeetCode_ 3 (longest substring without repeated characters)
Sharing the 12 most commonly used regular expressions can solve most of your problems
PHP5下WSDL,SOAP调用实现过程
What are the advantages and characteristics of SAS interface
R language dplyr package select function, group_ By function, mutate function and cumsum function calculate the cumulative value of the specified numerical variable in the dataframe grouping data and
Hongmeng fourth training