当前位置:网站首页>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 .
边栏推荐
- Thymeleaf th:with use of local variables
- POI set the data format of the column (valid)
- dynamic programming
- 3W principle [easy to understand]
- tidb-dm报警DM_sync_process_exists_with_error排查
- Section - left closed right open
- R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
- Postgresql 13 安装
- What are the advantages and characteristics of SAS interface
- 美国费城发生“安全事故” 2名警察遭枪杀
猜你喜欢

Thymeleaf 使用后台自定义工具类处理文本

Pointer operation - C language

区间 - 左闭右开

Redis如何实现多可用区?

freesurfer运行完recon-all怎么快速查看有没有报错?——核心命令tail重定向

APR protocol and defense

Shenziyu, the new chairman of Meizu: Mr. Huang Zhang, the founder, will serve as the strategic adviser of Meizu's scientific and technological products

魅族新任董事長沈子瑜:創始人黃章先生將作為魅族科技產品戰略顧問

openGauss数据库源码解析系列文章—— 密态等值查询技术详解(下)

Thymeleaf th:classappend attribute append th:styleappend style append th:data- custom attribute
随机推荐
Which Internet companies are worth going to in Shenzhen for software testers [Special Edition for software testers]
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
详解Vue适时清理keepalive缓存方案
魅族新任董事长沈子瑜:创始人黄章先生将作为魅族科技产品战略顾问
Thymeleaf 使用后台自定义工具类处理文本
R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
dynamic programming
做自媒体视频二次剪辑,怎样剪辑不算侵权
怎么叫一手一机的功能方式
享你所想。智创未来
Faire un clip vidéo auto - média deux fois, comment clip n'est pas considéré comme une infraction
Show strength. In this way, the mobile phone will not be difficult to move forward
Thymeleaf th:with局部变量的使用
最简单不用证书也可以多开功能的方式
ASP. Net large takeout ordering system source code (PC version + mobile version + merchant version)
Webrtc learning (II)
Enjoy what you want. Zhichuang future
展现强大。这样手机就不会难前进
openGauss数据库源码解析系列文章—— 密态等值查询技术详解(下)
What is the ranking of GF futures? Is it safe and reliable to open an account for GF futures online?