I have a table called "completedgames" it has two columns "GameID" and "gameresults"
I have this JSON inside the "gameresults" column
{
"gameID": "acaa2a99-a24c",
"scores": [
{
"id": "11888572",
"seen": false,
"score": 10
},
{
"id": "14916624",
"seen": false,
"score": 70
}
]
}
I need to set "seen" to true at a certain ID
I have come really close and tried many things and read a lot of documentation. The closest I have come is using this:
UPDATE completedgames SET gameresults = JSON_SET(gameresults, '$.scores[*].seen', true) WHERE GameId = 'acaa2a99-a24c' AND JSON_EXTRACT(gameresults, '$.scores[*].id') = '14916624';
but it does not work however if I specify the index that I know corresponds like this
UPDATE completedgames SET gameresults = JSON_SET(gameresults, '$.scores[1].seen', true) WHERE GameId = 'acaa2a99-a24c' AND JSON_EXTRACT(gameresults, '$.scores[1].id') = '14916624';
it works
I know I'm missing something small but I just can't seem to get it right.