John Derring John Derring - 1 month ago 44
MySQL Question

How to select from JSON field in MySQL 5.6 where json_extract is not available?

If my row has a

varchar
with the following value: "
[1,2,3]
", how could I select the whole row if I need the value to contain one of the numbers (a 2 or a 3)?

Answer

As you said, you're using MySQL 5.6, so the JSON_EXTRACT() function is not available.

The only options I would recommend are:

  1. Upgrade to MySQL 5.7

  2. Fetch the whole JSON document into an application and use a JSON decoding function.

You could also try to parse JSON using other string functions available in MySQL 5.6, but it'll be awkward and time-consuming to develop.