当前位置:网站首页> 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')以上为个人经验,希望能给大家一个参考,也希望大家多多支持软件开发网。
边栏推荐
- 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
- 魅族新任董事长沈子瑜:创始人黄章先生将作为魅族科技产品战略顾问
- How to protect user privacy without password authentication?
- R language ggplot2 visualization: use ggplot2 to visualize the scatter diagram, and use the labs parameter to customize the X axis label text (customize X axis labels)
- 如何深入理解“有限状态机”的设计思想?
- R语言ggplot2可视化:可视化折线图、使用theme函数中的legend.position参数自定义图例的位置
- Current situation, trend and view of neural network Internet of things in the future
- Implementation process of WSDL and soap calls under PHP5
- CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
- 汇编语言 assembly language
猜你喜欢

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

Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 2)

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

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

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

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

What are the advantages and characteristics of SAS interface

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

软件测试人在深圳有哪些值得去的互联网公司【软件测试人员专供版】

What category does the Internet of things application technology major belong to
随机推荐
POI set the data format of the column (valid)
R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
LeetCode_ 69 (square root of x)
不相交集
分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少
Principle and performance analysis of lepton lossless compression
Thymeleaf th:with局部变量的使用
[learning notes] stage test 1
Postman简介、安装、入门使用方法详细攻略!
Faire un clip vidéo auto - média deux fois, comment clip n'est pas considéré comme une infraction
最简单不用证书也可以多开功能的方式
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
How to make a second clip of our media video without infringement
如何深入理解“有限状态机”的设计思想?
世界环境日 | 周大福用心服务推动减碳环保
Thymeleaf common functions
C语言中限定符的作用
Mysql database installation tutorial under Linux
Loop invariant
R语言ggplot2可视化:可视化折线图、使用theme函数中的legend.position参数自定义图例的位置