当前位置:网站首页> mysql8.0JSON_CONTAINS的使用说明
mysql8.0JSON_CONTAINS的使用说明
2022-07-05 14:16:00 【1024问】
JSON_CONTAINS的使用
语法
案例
JSON_CONTAINS函数问题
结构如下
JSON_CONTAINS的使用语法JSON_CONTAINS(json_doc, val[, path])案例select * from tb where info->'$.name' = '特价促销' or JSON_CONTAINS(info->'$[*].name', '"特价促销"', '$')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函数问题mysql 存的是[14,15]这种数据结构 查询的解决办法
结构如下学生类:
@Column(value = "subject_ids", type = MySqlTypeConstant.TEXT)@ColumnComment(value = "科目。可多选,格式如[1,2,3]")private List<Long> subjectIds;数据库类型:text
mysql 存储类型: [14,15]
这个时候根据科目ID去查询有那些学生选择了14这个科目得时候就不能用in这个语法了
这个时候就可以使用
SELECT * FROM `t_student` where JSON_CONTAINS(subject_ids, '14')以上为个人经验,希望能给大家一个参考,也希望大家多多支持软件开发网。
边栏推荐
- R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
- Thymeleaf 常用函數
- The speed monitoring chip based on Bernoulli principle can be used for natural gas pipeline leakage detection
- R language ggplot2 visualization: visual line graph, using legend in theme function The position parameter defines the position of the legend
- Some ideas about Apache mesos
- What is the ranking of GF futures? Is it safe and reliable to open an account for GF futures online?
- tidb-dm报警DM_sync_process_exists_with_error排查
- 享你所想。智创未来
- Login interface code
- [buuctf.reverse] 152-154
猜你喜欢

Sharing the 12 most commonly used regular expressions can solve most of your problems

TiCDC 6.0原理之Sorter演进

ASP. Net large takeout ordering system source code (PC version + mobile version + merchant version)

Qingda KeYue rushes to the science and Innovation Board: the annual revenue is 200million, and it is proposed to raise 750million

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

魅族新任董事长沈子瑜:创始人黄章先生将作为魅族科技产品战略顾问

分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少

如何将 DevSecOps 引入企业?

网上电子元器件采购商城:打破采购环节信息不对称难题,赋能企业高效协同管理

Zhizhen new energy rushes to the scientific innovation board: the annual revenue is 220million, and SAIC venture capital is the shareholder
随机推荐
How to introduce devsecops into enterprises?
基于 TiDB 场景式技术架构过程 - 理论篇
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
汇编语言 assembly language
LeetCode_ 3 (longest substring without repeated characters)
物联网应用技术专业是属于什么类
Assembly language
Thymeleaf common functions
MySQL user-defined function ID number to age (supports 15 / 18 digit ID card)
What category does the Internet of things application technology major belong to
CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
Time to calculate cron expression based on cronsequencegenerator
01. Solr7.3.1 deployment and configuration of jetty under win10 platform
用“新”字来吸引好奇的人群
SSH免密码登录详解
R language uses the polR function of mass package to build an ordered multi classification logistic regression model, and uses the coef function to obtain the log odds ratio corresponding to each vari
无密码身份验证如何保障用户隐私安全?
Fault analysis | analysis of an example of MySQL running out of host memory
家用电器行业商业供应链协同平台解决方案:供应链系统管理精益化,助推企业智造升级
tidb-dm报警DM_sync_process_exists_with_error排查