当前位置:网站首页>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 .
边栏推荐
- R语言ggplot2可视化:使用ggplot2可视化散点图、使用labs参数自定义X轴的轴标签文本(customize X axis labels)
- Don't be unconvinced. Mobile phone function upgrade is strong
- 【学习笔记】阶段测试1
- ASP.NET大型外卖订餐系统源码 (PC版+手机版+商户版)
- 分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少
- 美国费城发生“安全事故” 2名警察遭枪杀
- Use the word "new" to attract curious people
- 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
- Make the seckill Carnival more leisurely: the database behind the promotion (Part 2)
- The simplest way to open more functions without certificates
猜你喜欢

TDengine 社区问题双周精选 | 第三期

Sorter evolution of ticdc 6.0 principle

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

Current situation, trend and view of neural network Internet of things in the future

The IPO of Ruineng industry was terminated: the annual revenue was 447million and it was planned to raise 376million

基于 TiDB 场景式技术架构过程 - 理论篇

让秒杀狂欢更从容:大促背后的数据库(下篇)

直播预告|如何借助自动化工具落地DevOps(文末福利)

Chow Tai Fook fulfills the "centenary commitment" and sincerely serves to promote green environmental protection

TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析
随机推荐
Section - left closed right open
Introduction, installation, introduction and detailed introduction to postman!
世界环境日 | 周大福用心服务推动减碳环保
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
Faire un clip vidéo auto - média deux fois, comment clip n'est pas considéré comme une infraction
关于memset赋值的探讨
Thymeleaf 常用函数
Longest common subsequence dynamic programming
Fonctions communes de thymeleaf
Time to calculate cron expression based on cronsequencegenerator
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
分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少
Postgresql 13 安装
【学习笔记】阶段测试1
美国费城发生“安全事故” 2名警察遭枪杀
How does redis implement multiple zones?
How to call the function mode of one hand and one machine
SaaS multi tenant solution for FMCG industry to build digital marketing competitiveness of the whole industry chain
R language ggplot2 visual bar graph: visualize the bar graph through the two-color gradient color theme, and add label text for each bar (geom_text function)
ASP. Net large takeout ordering system source code (PC version + mobile version + merchant version)