我正在寻找一种方法来查找行的json表的给定元素匹配的模式。
让我们从mysql表开始:
CREATE TABLE `person` (
`attributes` json DEFAULT NULL
);
INSERT INTO `person` (`attributes`)
VALUES ('[{"scores": 1, "name": "John"},{"scores": 1, "name": "Adam"}]');
INSERT INTO `person` (`attributes`)
VALUES ('[{"scores": 1, "name": "Johny"}]');
INSERT INTO `person` (`attributes`)
VALUES ('[{"scores": 1, "name": "Peter"}]');
如何找到属性[*].name包含John*
模式的所有记录?
在John*
的情况下,查询应该返回2条记录(包括John和Johny)。
1条答案
按热度按时间czfnxgou1#
https://sqlize.online/sql/mysql80/c9e4a3ffa159c4be8c761d696e06d946/