当前位置:网站首页>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
边栏推荐
- 1002 写出这个数 (20 分)
- Analysys and the Alliance of Small and Medium Banks jointly released the Hainan Digital Economy Index, so stay tuned!
- 1081 检查密码 (15 分)
- 【LeetCode每日一题】——682.棒球比赛
- 求职简历这样写,轻松搞定面试官
- Evolution and New Choice of Streaming Structured Data Computing Language
- 从何跟踪伦敦金最新行情走势?
- Project 1 - PM2.5 Forecast
- Service的两种启动方式与区别
- Distributed Lock-Redission - Cache Consistency Solution
猜你喜欢
随机推荐
DDR4内存条电路设计
MindManager2022全新正式免费思维导图更新
Square, multi-power, square root calculation in Tf
js判断图片是否存在
My creative anniversary丨Thank you for being with you for these 365 days, not forgetting the original intention, and each is wonderful
1036 Programming with Obama (15 points)
结合均线分析k线图的基本知识
The easiest trick to support quick renaming of various files
The softmax function is used in TF;
1076 Wifi密码 (15 分)
1.2-误差来源
tf.reduce_mean()与tf.reduce_sum()
Service的两种状态形式
年薪40W测试工程师成长之路,你在哪个阶段?
Pico neo3 Unity Packaging Settings
1002 写出这个数 (20 分)
Pico neo3 Unity打包设置
1061 True or False (15 points)
1096 big beautiful numbers (15 points)
经典论文-MobileNet V1论文及实践