update new_calls_display set city_id = '3' where cus_city like '%Madurai%'
以上mysql查询我想动态更改city_id值,并且相应的cus_city也会使用php编码从当前表(new_calls_display)动态更改
city_id cus_city
1 Chennai
2 Ariyalur
2 Ariyalur
3 Madurai
3 Madurai
3 Madurai
1 Chennai
1 Chennai
像上面的表cus_id 1到50所以cus_city也有50个唯一值
答案 0 :(得分:0)
您需要使用变量,然后将其连接到sql查询字符串:
$idcity = 2;
"update new_calls_display set city_id = {$idcity} where cus_city like '%Madurai%'"
不要忘记处理sql注入,以前的代码可以轻松入侵。
答案 1 :(得分:0)
update new_calls_display
set city_id = (
select col_name from table_name where cus_city like '%Madurai%' )