I have a json column named Data in my user table in the database.
Example of content:
[
{
"id": 10,
"key": "mail",
"type": "male",
},
{
"id": 5,
"key": "name",
"type": "female",
},
{
"id": 8,
"key": "mail",
"type": "female",
}
]
let's assume that many row in the table may have the same content so they should be removed from all of the rows of the table too what i want to do is remove an item by key and value last thing i can come up with is this query for example i want to remove the item where id equal 10:
UPDATE
user
SET
`Data` =
JSON_REMOVE(`Data`,JSON_SEARCH(`Data`,'all',10,NULL,'$[*].id'),10)
but this query remove the all the content of the column.
If any one could help this is much appreciated.
By the way i get on this way because i can't seem to find a way to make it using QueryBuilder in laravel So it will be RawQuery.
Thank you Guys