- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果我这样做: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
。
最佳答案
json_remove
、json_set
等函数好像MySQL不支持通配符
bool Item_func_json_remove::val_json(Json_wrapper *wr)
{
//bla-bla-bla
if (m_path_cache.parse_and_cache_path(args, path_idx + 1, true))
}
和
bool Json_path_cache::parse_and_cache_path(Item ** args, uint arg_idx,
bool forbid_wildcards)
https://github.com/mysql/mysql-server/blob/5.7/sql/item_json_func.cc#L3227 https://github.com/mysql/mysql-server/blob/5.7/sql/item_json_func.cc#L2563 https://github.com/mysql/mysql-server/blob/5.7/sql/item_json_func.cc#L534
关于mysql - array.array 的 JSON_REMOVE 导致 "path expressions may not contain the * and ** tokens"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38890938/
我将以下 JSON 文档存储在名为 my_data 的 MySQL 8 列中: { "managers": { "11": { "created": "2019-11-07"
我有一个名为 product_option_param 的表,其中有一列 povs 是 JSON 类型,它基本上保留了带有 id 的 JSON 数组(例如,[1,2 ,3]) 当我需要删除,例如,一个
我有一个 mysql json 字段(交互),它包含如下值: {"likes": [ ['1:scott'], ['2:james'] ] } 我希望能
非常简单,我在 MySQL 中有以下 JSON: {"car" : ["honda","ferrari"]} 我想单独在“本田”上使用 JSON_REMOVE,但我找不到如何制定路径。我以为会是这样,
我有 channel 表: +----+-------------------+---------+ | id | sort | bouquet | +----+------
我正在尝试从 MySQL 中的 JSON 数组中删除对象。 我有一个名为 cart 的表,其中有两个字段 quote_id 类型 int 和 items 类型 json ,其内容如下存储在 MySQL
如果我这样做:SELECT JSON_REMOVE(@I, '$.friends[*].name'); 或 SELECT JSON_REMOVE(@I, '$.friends[*]. friends'
我是一名优秀的程序员,十分优秀!