Is it possible to remove a JSON array element by value in MySQL?
3
votes
3
answers
15528
views
In MySQL, it's possible to remove an array element by index:
SELECT JSON_REMOVE('["a", "b", "c"]', '$') result
;
+------------+
| result |
+------------+
| ["a", "c"] |
+------------+
Is it possible to remove by value instead - in this case the element(s) matching the string "b"
?
Based on the documentation, it's possible to find the index via JSON_SEARCH
and then passing it to JSON_REMOVE
, however, I was wondering if there's an expression/function to do it in a single function.
Asked by Marcus
(390 rep)
Jun 7, 2021, 08:12 AM
Last activity: May 2, 2023, 07:17 PM
Last activity: May 2, 2023, 07:17 PM