当前位置:网站首页>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
边栏推荐
- Four startup modes of Activity
- 项目2-年收入判断
- Dynamic Agent Learning
- 动态代理学习
- Do you know the basic process and use case design method of interface testing?
- 【sdx62】XBL设置共享内存变量,然后内核层获取变量实现
- 关于#sql#的问题:怎么将下面的数据按逗号分隔成多行,以列的形式展示出来
- 2022 China Soft Drink Market Insights
- 3.1-Classification-probabilistic generative model
- 2.1-梯度下降
猜你喜欢
随机推荐
2022-08-10 mysql/stonedb-慢SQL-Q16-耗时追踪
1046 划拳 (15 分)
1081 Check Password (15 points)
伦敦银规则有哪些?
Four operations in TF
场地预订系统,帮助场馆提高坪效
1096 big beautiful numbers (15 points)
【Pytorch】nn.PixelShuffle
国密规范 SM2 SM3 SM4
数仓开发知识总结
MindManager2022全新正式免费思维导图更新
软件测试常用工具的用途及优缺点比较(详细)
项目1-PM2.5预测
1076 Wifi Password (15 points)
Tensorflow中使用tf.argmax返回张量沿指定维度最大值的索引
js判断图片是否存在
leetcode:69. x 的平方根
1051 Multiplication of Complex Numbers (15 points)
go-grpc TSL认证 解决 transport: authentication handshake failed: x509 certificate relies on ... ...
【Pytorch】nn.ReLU(inplace=True)