表结构如下:
表里有个json类型字段use_rule
CREATE TABLE `test` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`use_rule` json NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4;
INSERT INTO `` (`id`,`use_rule`) values
(1,{"year_id": 13, "subject_ids": [19]}),
(2,{"year_id": 13, "subject_ids": [20]}),
(3,{"year_id": 13, "subject_ids": [21]}),
(4,{"year_id": 13, "subject_ids": [20, 21]}),
(5,{"year_id": 13, "subject_ids": [19, 20, 21]});
比如输入19,20,查询出use_rule字段subject_ids里所有含19,20的数据,也就是id为1,2,4,5的数据。sql该怎么写