当前位置:网站首页>Mysql JSON对象和JSON数组查询
Mysql JSON对象和JSON数组查询
2022-08-11 07:28:00 【wnfee】

file_type
可以是 varchar
,也可以是 json
类型 1. JSON对象
{"key": 1, "name": "万飞"}
查询
SELECT * FROM `ak_file_config` where file_type -> '$.name' = "万飞"
2. 字符串JSON数组
["EXE", "白加黑", "DLL"]
查询
SELECT * FROM `ak_file_config` where JSON_CONTAINS(file_type, JSON_ARRAY("白加黑","DLL"))
3. 对象数组
4. 集成 Mybatis plus
// jsonArray查询
.apply(CollUtil.isNotEmpty(query.getFileType()), StrUtil.format("JSON_CONTAINS(t.file_type, JSON_ARRAY({}))",
// 设置占位符{0},{1},{2}
IntStream.range(0, Optional.ofNullable(query.getFileType()).orElse(Collections.emptyList()).size())
.mapToObj(i -> "{".concat(String.valueOf(i)).concat("}"))
.collect(Collectors.joining(","))),
Optional.ofNullable(query.getFileType()).orElse(Collections.emptyList()).toArray())
参考 https://blog.csdn.net/qq_31832209/article/details/125374325
边栏推荐
猜你喜欢
1.2 - error sources
Hibernate 的 Session 缓存相关操作
3.2 - classification - Logistic regression
Project 1 - PM2.5 Forecast
The growth path of a 40W test engineer with an annual salary, which stage are you in?
1096 大美数 (15 分)
matrix multiplication in tf
1036 Programming with Obama (15 points)
The softmax function is used in TF;
软件测试常用工具的用途及优缺点比较(详细)
随机推荐
redis操作
My creative anniversary丨Thank you for being with you for these 365 days, not forgetting the original intention, and each is wonderful
3GPP LTE/NR信道模型
Active users of mobile banking grew rapidly in June, hitting a half-year high
6月各手机银行活跃用户较快增长,创半年新高
项目2-年收入判断
Four startup modes of Activity
记录一些遇见的bug——Lombok和Mapstruct的冲突导致,A component required a bean of type ‘com.XXX.controller.converter.
1101 B是A的多少倍 (15 分)
Activity的四种启动模式
The most complete documentation on Excel's implementation of grouped summation
1003 我要通过 (20 分)
1003 I want to pass (20 points)
The easiest trick to support quick renaming of various files
2022-08-10 mysql/stonedb-slow SQL-Q16-time-consuming tracking
1.2-误差来源
零基础SQL教程: 基础查询 05
Item 2 - Annual Income Judgment
3.1-分类-概率生成模型
break pad源码编译--参考大佬博客的总结