By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE table1 (
`id` INTEGER,
`val` JSON
);
INSERT INTO table1
VALUES
('1', '{"stdId":1,"stdName":"student","stdAddress":"testLoc","stdran":[1,2,3]}'),
('2', '{"stdId":2,"stdName":"student2","stdAddress":"testLoc","stdran":[1,2,3,4]}'),
('3', '{"stdId":3,"stdName":"student3","stdAddress":"testLoc","stdran":[1]}'),
('4', '{"stdId":4,"stdName":"student4","stdAddress":"testLoc","stdran":[2,3]}');
SELECT id FROM table1 WHERE JSON_CONTAINS(val,'1', '$.stdran') ;
id |
---|
1 |
2 |
3 |