当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
年薪40W测试工程师成长之路,你在哪个阶段?
【C语言】每日一题,求水仙花数,求变种水仙花数
oracle19c does not support real-time synchronization parameters, do you guys have any good solutions?
通过记账,了解当月收支情况
tf.reduce_mean()与tf.reduce_sum()
Square, multi-power, square root calculation in Tf
JRS303-数据校验
2.1-梯度下降
流式结构化数据计算语言的进化与新选择
1091 N-Defensive Number (15 points)
CIKM 2022 AnalytiCup Competition: 联邦异质任务学习
求职简历这样写,轻松搞定面试官
3.1-Classification-probabilistic generative model
Pico neo3 Unity Packaging Settings
matplotlib
The easiest trick to support quick renaming of various files
欢迎加入sumarua网络安全交流社区
string类接口介绍及应用
Four states of Activity
线程交替输出(你能想出几种方法)









