当前位置:网站首页>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 .
边栏推荐
- 不相交集
- 日化用品行业智能供应链协同系统解决方案:数智化SCM供应链,为企业转型“加速度”
- Thymeleaf common functions
- Show strength. In this way, the mobile phone will not be difficult to move forward
- Matrix chain multiplication dynamic programming example
- 04_ Use of solrj7.3 of solr7.3
- Tiflash compiler oriented automatic vectorization acceleration
- R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
- Lepton 无损压缩原理及性能分析
- Tdengine biweekly selection of community issues | phase III
猜你喜欢
如何深入理解“有限状态机”的设计思想?
Pointer operation - C language
Sorter evolution of ticdc 6.0 principle
非技术部门,如何参与 DevOps?
Kunlun Taike rushes to the scientific innovation board: the annual revenue is 130million, and it plans to raise 500million. CETC Taiji holds 40% of the shares
Intelligent supply chain collaboration system solution for daily chemical products industry: digital intelligent SCM supply chain, which is the "acceleration" of enterprise transformation
How does redis implement multiple zones?
直播预告|如何借助自动化工具落地DevOps(文末福利)
[learning notes] stage test 1
How can non-technical departments participate in Devops?
随机推荐
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 常用函数
Pointer operation - C language
网上电子元器件采购商城:打破采购环节信息不对称难题,赋能企业高效协同管理
The forked VM terminated without saying properly goodbye
别不服气。手机功能升级就是强
The IPO of Ruineng industry was terminated: the annual revenue was 447million and it was planned to raise 376million
微服务项目部署后,无法访问静态资源,无法访问到上传到upload中的文件,解决办法
Introduction, installation, introduction and detailed introduction to postman!
How does redis implement multiple zones?
C语言中限定符的作用
最长公共子序列 - 动态规划
How to introduce devsecops into enterprises?
注意!软件供应链安全挑战持续升级
让秒杀狂欢更从容:大促背后的数据库(下篇)
R语言ggplot2可视化密度图:按照分组可视化密度图、自定义配置geom_density函数中的alpha参数设置图像透明度(防止多条密度曲线互相遮挡)
Fonctions communes de thymeleaf
Share 20 strange JS expressions and see how many correct answers you can get
如何深入理解“有限状态机”的设计思想?
Thymeleaf common functions