I need to remove multiple values from JSON Array in MySQL
I've tried JSON_REMOVE with JSON_SEARCH on each value but after removing element the INDEX changes
JSON Array:
["1", "5", "18", "68"]
for example : remove "5" and "68"
expected result :
["1", "18"]
EDITED:
code that I've tried:
JSON_REMOVE(`can_see`, JSON_UNQUOTE(JSON_SEARCH(`can_see`, 'one', '5')), JSON_UNQUOTE(JSON_SEARCH(`can_see`, 'one', '68')))
query result:
["1", "18", "68"]
after removing "5" at index $[0], "68" index changed to $[2] but the JSON_SEARCH return $[3] from the original json
I also tried nested :
JSON_REMOVE(JSON_REMOVE(`can_see`, JSON_UNQUOTE(JSON_SEARCH(`can_see`, 'one', '5'))), JSON_UNQUOTE(JSON_SEARCH(JSON_REMOVE(`can_see`, JSON_UNQUOTE(JSON_SEARCH(`can_see`, 'one', '5'))), 'one', '68')))
that works but it gets messy if i want to remove more than 2 values