0

I have some json data in video_status_ids in mysql, I am trying to retrieve all records having 3

MySql version: 5.7.23 

Demo records

[3, 6, 9]

[7, 3, 10] 

Query

SELECT * FROM `videos` WHERE JSON_SEARCH(video_status_ids, "one", 3);

Resulting 0 records

1 Answer 1

2

you would be better off with JSON_CONTAINS

SQL > select * from zz where json_contains(doc,'3');
+-----+------------+
| _id | doc        |
+-----+------------+
|   1 | [3, 6, 9]  |
|   2 | [7, 3, 10] |
+-----+------------+
2 rows in set (0.0007 sec)

And lets make sure that that it acts correctly on values we do not have

SQL > select * from zz where json_contains(doc,'2');
Empty set (0.0006 sec)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.