当前位置:网站首页>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
边栏推荐
猜你喜欢

Keep track of your monthly income and expenses through bookkeeping

XXL-JOB 分布式任务调度中心搭建

Use tf.argmax in Tensorflow to return the index of the maximum value of the tensor along the specified dimension

TF中的四则运算

数仓开发知识总结

The softmax function is used in TF;

TF中的One-hot

tf中自减操作;tf.assign_sub()

JRS303-Data Verification

零基础SQL教程: 基础查询 05
随机推荐
初级软件测试工程师笔试试题,你知道答案吗?
TF中的条件语句;where()
Interaction of Pico neo3 in Unity
2.1 - Gradient Descent
Redis source code-String: Redis String command, Redis String storage principle, three encoding types of Redis string, Redis String SDS source code analysis, Redis String application scenarios
无服务器+域名也能搭建个人博客?真的,而且很快
Unity开发者必备的C#脚本技巧
流式结构化数据计算语言的进化与新选择
测试用例很难?有手就行
1096 big beautiful numbers (15 points)
1002 Write the number (20 points)
1091 N-自守数 (15 分)
囍楽cloud task source code
Active users of mobile banking grew rapidly in June, hitting a half-year high
我的创作纪念日丨感恩这365天来有你相伴,不忘初心,各自精彩
选择收银系统主要看哪些方面?
1046 punches (15 points)
1056 Sum of Combinations (15 points)
3GPP LTE/NR信道模型
Evolution and New Choice of Streaming Structured Data Computing Language