【无标题】

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'), '$');

执行结果:

相关推荐
bloglin999994 小时前
scp、rsync远程文件同步
linux·运维·服务器
迦南的迦 亚索的索4 小时前
LINUX环境
linux·运维·服务器
yuanjj884 小时前
linux下调试域格CLM920 NC5等9x07平台模块 QMI拨号
linux·运维·服务器
懂懂tty4 小时前
React状态更新流程
前端·react.js
IMPYLH4 小时前
Linux 的 printenv 命令
linux·运维·服务器·bash
SilentSamsara4 小时前
SSH 远程管理:密钥登录 + 隧道转发,一次性配置好
linux·运维·服务器·ubuntu·centos·ssh
小码哥_常5 小时前
告别繁琐!手把手教你封装超实用Android原生Adapter基类
前端
HoneyMoose5 小时前
Jenkins Cloudflare 部署提示错误
java·servlet·jenkins
阿丰资源5 小时前
基于SpringBoot的物流信息管理系统设计与实现(附资料)
java·spring boot·后端
skywalk81635 小时前
pytest测试的时候这是什么意思?Migrating <class ‘kotti.resources.File‘>
前端·python