I have a table with JSON data like this:
{\"a\": [{\"color\": \"blue\", \"value\": 15}, {\"color\": \"red\", \"value\": 30}]}
I need to get
Use JSON_SEARCH() to find the path to blue.
JSON_SEARCH()
blue
SELECT JSON_EXTRACT(my_data, REPLACE(JSON_SEARCH(my_data, 'one', 'blue'), '.color', '.value'))
JSON_SEARCH will return a string like $.a[0].color. REPLACE changes that to $.a[0].value, then you extract that element.
JSON_SEARCH
$.a[0].color
REPLACE
$.a[0].value