A
A
Alexander2017-10-20 15:27:24
MySQL
Alexander, 2017-10-20 15:27:24

JSON search in MySQL 5.7?

How to select elements where categoriesId = 4
There is a column: depend it stores a JSON array like:
{"brandsId": [145, 15, 141, 1001, 93, 657], "categoriesId": [41, 4, 65, 24, 218, 890]}
I need to find all entries where categoriesId = 4

select * from `services` where `dependencies`->"$.categoriesId" = 4 - не работает

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2017-10-20
@0xD34F

Try like this:

SELECT *
FROM `services`
WHERE JSON_CONTAINS(`dependencies`, '4', '$.categoriesId')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question