shalomew
shalomew

Reputation: 49

How can I remove an element from a JSON array using MySQL?

I have a table with JSON data like this:

{"entries": [{"color": "blue", "value": 15, "name": "john"}, {"color": "red", "value": 30, "name": "doe"}]}

I need to remove the object in the array that has value x.

The code I have so far is:

SELECT data_source, JSON_EXTRACT('$.entries[*].value')

Which allows me to see all the values in an array.

I would like to do something like:

SELECT JSON_REMOVE(data_source, '$.entries[*].use_id') = x

How can I create a JSON path that would allow me to find the value? And then remove that object it's in?

Upvotes: 0

Views: 15

Answers (0)

Related Questions