gpt4 book ai didi

MySQL服务器-更新键值对中的值

转载 作者:行者123 更新时间:2023-11-29 11:11:57 41 4
gpt4 key购买 nike

enter image description here

我想使用其关键 features_title_1 将数据 Training Classess 更新为 Training,并且还想对中的其余记录执行相同的操作单个查询..我将如何执行此操作?

我知道我的查询是错误的,但它就是......任何帮助将不胜感激......

"update home_content set 
`features_title_1` ='Training Classes' ,
`features_title_2` ='Happy Clients' ,
`features_title_3` ='Trainings Rooms' ,
`gender_title_women` ='For Womendsd',
`gender_desc_women` ='Nulla sed lacus vitae risus,
`gender_title_men` ='For Men',
`gender_desc_men` ='Nulla sed lacus vitae."

最佳答案

你可以在执行mysql查询之前简单地创建一个数组
像这样

$DataAarray =  array("features_title_1"    =>'Training Classes' , 
"features_title_2" =>'Happy Clients' ,
"features_title_3" =>'Trainings Rooms' ,
"gender_title_women" =>'For Womendsd',
"gender_desc_women" =>'Nulla sed lacus vitae risus',
"gender_title_men" =>'For Men',
"gender_desc_men" =>'Nulla sed lacus vitae');

然后你可以像这样使用foreach,在foreach中你可以执行mysql更新查询

foreach($DataAarray as $Key => $value){            
//Updte query here
UPDATE `table` SET `value` = $value WHERE `mkey` = $Key;
}

关于MySQL服务器-更新键值对中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40418417/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com