文档
- https://dev.mysql.com/doc/refman/8.0/en/json.html
- https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html
方法
JSON_CONTAINS(target, candidate[, path]) value MEMBER OF(json_array)
查询示例
mysql> set @list = JSON_ARRAY(1, 2); Query OK, 0 rows affected (0.01 sec) mysql> select 1 MEMBER OF(@list); +--------------------+ | 1 MEMBER OF(@list) | +--------------------+ | 1 | +--------------------+ 1 row in set (0.00 sec) mysql> SELECT JSON_CONTAINS(@list, '1'); +---------------------------+ | JSON_CONTAINS(@list, '1') | +---------------------------+ | 1 | +---------------------------+ 1 row in set (0.01 sec)
文章知识点与官方知识档案匹配,可进一步学习相关知识