如果我这样做: SELECT JSON_REMOVE(@I, '$.friends[*].name');
或者SELECT JSON_REMOVE(@I, '$.friends[*].friends');
在下面的 JSON 上,我得到这个错误:
ERROR 3149 (42000): In this situation, path expressions may not contain the * and ** tokens.
JSON:
SET @I = '{
"name": "Alice",
"friends": [
{
"name": "Bob",
"friends": [
{
"name": "Carl",
"friends": []
},
{
"name": "Danny",
"friends": []
}
]
},
{
"name": "Edward",
"friends": [
{
"name": "Frank",
"friends": []
},
{
"name": "Gary",
"friends": []
}
]
}
]
}';
但是,如果我这样做SELECT JSON_EXTRACT(@I, '$.friends[*].friends')
,它会很好地返回结果。
[[{"friends": [], "name": "Carl"}, {"friends": [], "name": "Danny"}], [{"name": "Frank", "friends": []}, {"name": "Gary", "friends": []}]]
基本上我想返回一个全部friends.name
删除甚至friends.friends
删除的字符串。