Reputation: 35
Example the data
column has
{"default_account":188,"default_bu-207":948}
update user_preference
set data = JSON_REMOVE(data,'$.default_bu-207')
where JSON_EXTRACT(data,'$.default_bu-207') = 948
for this query i am getting error
Invalid JSON path expression.
The error is around character position 16.*
tried escaping -
but it is throwing same error
Upvotes: 0
Views: 50
Reputation: 562871
https://dev.mysql.com/doc/refman/8.0/en/json.html says:
JSON Path Syntax
...
Names of keys must be double-quoted strings or valid ECMAScript identifiers (see Identifier Names and Identifiers, in the ECMAScript Language Specification).
Since your key name contains a punctuation character, you must use double quotes:
... JSON_REMOVE(data,'$."default_bu-207"') ...
Upvotes: 2