It may be simple enough with basic SQL or REGEXP may be required, but I hit a brick wall.
My data is stored in a JSON string, like these two examples (each in 1 field):
[{"id": "2", "value": ["1", "3"]}, {"id": "3", "value": ["1", "2"]}]
and
[{"id": "3", "value": ["2"]}, {"id": "3", "value": ["1", "2", "5"]}]
I want to find the meanings between these last brackets, which can consist of many numbers ["1","2","5"] or just a single on ["2"] . The initial digits correspond to two categories - single "id":"2" and "id":"3" .
Using %"2"% with a simple LIKE certainly fits all. I can request "id":"$var" to return each category, and then use PHP to filter it after we get the results, but the data can be quite large, and I'm sure this is easy for the SQL guru .
I have no way to change the format of the field, it should remain as JSON.
Any help appreciated! Thanks.
sql regex mysql
stabbie
source share