当前位置:网站首页>mysql8.0JSON_ Instructions for using contains
mysql8.0JSON_ Instructions for using contains
2022-07-05 14:25:00 【1024 questions】
JSON_CONTAINS Use
grammar
Case study
JSON_CONTAINS Function problem
The structure is as follows
JSON_CONTAINS Use grammarJSON_CONTAINS(json_doc, val[, path])
Case study select * from tb where info->'$.name' = ' Special promotion ' or JSON_CONTAINS(info->'$[*].name', '" Special promotion "', '$')
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 Function problem mysql Deposit is [14,15] This data structure Solution to query
The structure is as followsStudents :
@Column(value = "subject_ids", type = MySqlTypeConstant.TEXT)@ColumnComment(value = " subject . You can choose more , The format is as follows [1,2,3]")private List<Long> subjectIds;
Database type :text
mysql Storage type : [14,15]
At this time, according to the subject ID Check which students have chosen 14 You can't use this subject when you have to in This grammar
It can be used at this time
SELECT * FROM `t_student` where JSON_CONTAINS(subject_ids, '14')
The above is personal experience , I hope I can give you a reference , I also hope you can support the software development network .
边栏推荐
- 非技术部门,如何参与 DevOps?
- ASP. Net large takeout ordering system source code (PC version + mobile version + merchant version)
- Guofu hydrogen energy rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, and 360million yuan of accounts receivable exceed the revenue
- LeetCode_ 67 (binary sum)
- 关于memset赋值的探讨
- 循环不变式
- How to call the function mode of one hand and one machine
- 乌卡时代下,企业供应链管理体系的应对策略
- Disjoint Set
- tidb-dm报警DM_sync_process_exists_with_error排查
猜你喜欢
TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析
TDengine 社区问题双周精选 | 第三期
【学习笔记】阶段测试1
世界环境日 | 周大福用心服务推动减碳环保
区间 - 左闭右开
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
Thymeleaf th:with局部变量的使用
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
Thymeleaf th:classappend attribute append th:styleappend style append th:data- custom attribute
Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 2)
随机推荐
R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析
Online electronic component purchasing Mall: break the problem of information asymmetry in the purchasing process, and enable enterprises to effectively coordinate management
动态规划
C language -- structure and function
Zhizhen new energy rushes to the scientific innovation board: the annual revenue is 220million, and SAIC venture capital is the shareholder
不相交集
Geom of R language using ggplot2 package_ Histogram function visual histogram (histogram plot)
R语言ggplot2可视化密度图:按照分组可视化密度图、自定义配置geom_density函数中的alpha参数设置图像透明度(防止多条密度曲线互相遮挡)
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
Webrtc learning (II)
What is the future development trend of neural network Internet of things
Disjoint Set
Interpretation of tiflash source code (IV) | design and implementation analysis of tiflash DDL module
R语言使用原生包(基础导入包、graphics)中的boxplot函数可视化箱图(box plot)
微服务项目部署后,无法访问静态资源,无法访问到上传到upload中的文件,解决办法
无密码身份验证如何保障用户隐私安全?
【学习笔记】阶段测试1
What category does the Internet of things application technology major belong to
Chow Tai Fook fulfills the "centenary commitment" and sincerely serves to promote green environmental protection