【无标题】

1、创建表:

sql 复制代码
DROP TABLE IF EXISTS `client`;
CREATE TABLE `client`  (
  `id` int NOT NULL AUTO_INCREMENT,
  `client_ids` json NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of client
-- ----------------------------
INSERT INTO `client` VALUES (1, '[\"a\", \"b\"]');
INSERT INTO `client` VALUES (2, '[\"a\", \"ab\"]');

2、查询json数组中含有"b"元素的记录:("ab" 不算 "b")

sql 复制代码
select * from client t where JSON_CONTAINS(t.client_ids, JSON_ARRAY('b'), '$');

执行结果:

相关推荐
真夜3 小时前
RN热更新安全问题
前端·react native
Zeroplucky3 小时前
Binder 线程池耗尽案例:持锁同步调用 VHAL 导致 SystemUI 卡顿或 ANR
前端
Zeroplucky3 小时前
从 registerContentObserver 剖析 Android Binder 流程
前端
wear工程师3 小时前
线程池队列满了会怎样?从拒绝策略看懂 ThreadPoolExecutor 的扩容顺序
java
晓晓_za8986683 小时前
多租户 GEO 优化系统源码架构:权限隔离与数据分离实现
java·tcp/ip·spring·缓存·微服务·架构
Yinlin1243 小时前
深入悬浮组件实现
前端
AI行业应用研究3 小时前
2026年主流报名工具测评报告:眨眼猫会务智能体报名小程序为何成为多场景首选?
java·开发语言·小程序
yangzheui3 小时前
nvue页面事件穿透到下层元素解决办法
前端
杉氧3 小时前
从 Modifier 到 Flexbox:React Native 布局与样式设计哲学
android·前端·react native
AlanBruce3 小时前
一键设备扫描功能详解
服务器·网络·网络协议·modbus·摩尔信使·设备扫描