当前位置:网站首页>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 .
边栏推荐
- CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
- The IPO of Ruineng industry was terminated: the annual revenue was 447million and it was planned to raise 376million
- Redis如何实现多可用区?
- 强联通分量
- 展现强大。这样手机就不会难前进
- 美国费城发生“安全事故” 2名警察遭枪杀
- R Language ggplot2 Visualization: visualize linegraph, using Legend in Theme function. Paramètre de position emplacement de la légende personnalisée
- How to protect user privacy without password authentication?
- Fonctions communes de thymeleaf
- Loop invariant
猜你喜欢
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
Make the seckill Carnival more leisurely: the database behind the promotion (Part 2)
[learning notes] stage test 1
Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 2)
Security analysis of Web Architecture
Pointer operation - C language
How can non-technical departments participate in Devops?
Countermeasures of enterprise supply chain management system in UCA Era
leetcode:881. 救生艇
Postman简介、安装、入门使用方法详细攻略!
随机推荐
R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the coef function to obtain the log odds ratio corresponding to eac
Principle and performance analysis of lepton lossless compression
Thymeleaf 常用函數
Thymeleaf th:with局部变量的使用
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
What is the future development trend of neural network Internet of things
R language ggplot2 visualization: visual line graph, using legend in theme function The position parameter defines the position of the legend
详解Vue适时清理keepalive缓存方案
What category does the Internet of things application technology major belong to
How to introduce devsecops into enterprises?
Show strength. In this way, the mobile phone will not be difficult to move forward
The simplest way to open more functions without certificates
Interpretation of tiflash source code (IV) | design and implementation analysis of tiflash DDL module
动态规划
PMP考试20天能通过吗?
Postgresql 13 安装
Why do mechanical engineers I know complain about low wages?
TiFlash 面向编译器的自动向量化加速
ASP.NET大型外卖订餐系统源码 (PC版+手机版+商户版)
[learning notes] stage test 1