I have a test table in which there is a json field with a JSON data format.
In this field is an array [2, 3, 4, 5].
I want to remove C grade from an array. And successfully do it with the following query:
UPDATE test SET json = JSON_REMOVE(json, '$[1]') WHERE `id` = 2; But what if I know that there is an element in the array with a value of 3, but I do not know its index?
Trying to execute the following query:
UPDATE test SET json = JSON_REMOVE( json, '$[ JSON_SEARCH(json, 'one', 3) ]' ) WHERE `id` = 2; I get a syntax error.
What am I doing wrong?