Answer the question
In order to leave comments, you need to log in
How to find row in mysql where json array value is equal to value?
How to find something like:
SELECT * FROM test WHERE array_test.value = 2;
and that it displays a row with id=2;
mysql> select * from test;
+----+----------------------------+
| id | array_test |
+----+----------------------------+
| 2 | [1, 2, "asd", true] |
| 3 | {"0": "false", "1": "one"} |
+----+----------------------------+
2 rows in set (0,00 sec)
Answer the question
In order to leave comments, you need to log in
As a demonstration that "The server is smarter than you think!":
SELECT id, CAST(array_test AS CHAR) array_test
FROM test
WHERE JSON_OVERLAPS(array_test, CAST('[2]' AS JSON));
This is a search on the array_test column, if "2", "yvayv2", "utsatsu2autsats" hits. Will output them to the result
SELECT * FROM `test` WHERE `array_test` LIKE '%2%'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question