如果值匹配某些条件,MySql Json 替换特定索引处的数组值
例子:
{
"deploy": [
"Infrastructure",
"API Security"
],
"operate": [
"Pen Testing",
"Bug Bounty"
]
}
Run Code Online (Sandbox Code Playgroud)
这里我想用基础设施工具代替基础设施的价值
在此示例中,基础设施的索引为 0,但这可能因其他行而异
我试图解决这个问题的查询是
update table_config
set config = JSON_SET(config,JSON_SEARCH(config,'one',"Infrastructure"),"Infrastructure");
Run Code Online (Sandbox Code Playgroud)
哪个不运行
以下是我的表格:
CREATE TABLE `table_config` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`config` longtext,
`type` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
)
Run Code Online (Sandbox Code Playgroud)