For reasons I can't control, I need to parse a json column in MYSQL for all of the instances of a key and then get the max of those. Let's say the column name is json_data and the json looks like this:
{
list_of_stuff: {
{
value_i_want: 1
},
{
value_i_want: 2
},
{
value_i_want: 4
},
{
value_i_want: 3
}
}
}
Where I would need to get the maximum of the value_i_want tag, which in this case would be 4.
Right now I have the following code:
SELECT JSON_EXTRACT(json_data->"$.list_of_stuff", "$**.value_i_want") from table_name;
But it is returning JSON arrays, and when I try to get the maximum of those arrays, it is just returning the row with the longest json array, not the maximum value of each of those arrays.
Thanks for your help!
EDIT My MYSQL version is 5.7.25