当前位置:网站首页>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
边栏推荐
猜你喜欢
经典论文-MobileNet V1论文及实践
3.2 - classification - Logistic regression
Active users of mobile banking grew rapidly in June, hitting a half-year high
1071 Small Gamble (15 points)
【TA-霜狼_may-《百人计划》】图形3.7.2 command buffer简
1076 Wifi密码 (15 分)
Use tf.argmax in Tensorflow to return the index of the maximum value of the tensor along the specified dimension
1.1-回归
1002 Write the number (20 points)
The most complete documentation on Excel's implementation of grouped summation
随机推荐
1106 2019 Sequence (15 points)
【43. 字符串相乘】
Find the latest staff salary and the last staff salary changes
租房小程序
【LeetCode】Summary of linked list problems
易观分析联合中小银行联盟发布海南数字经济指数,敬请期待!
matplotlib
项目1-PM2.5预测
JRS303-Data Verification
零基础SQL教程: 基础查询 05
Decrement operation in tf; tf.assign_sub()
【latex异常和错误】Missing $ inserted.<inserted text>You can‘t use \spacefactor in math mode.输出文本要注意特殊字符的转义
软件测试常用工具的用途及优缺点比较(详细)
年薪40W测试工程师成长之路,你在哪个阶段?
1046 punches (15 points)
1.2-误差来源
JRS303-数据校验
1046 划拳 (15 分)
Conditional statements in TF; where()
我的创作纪念日丨感恩这365天来有你相伴,不忘初心,各自精彩