求这样的一句MYSQL语句 现在,数据库里有一个两个字段code city01001001002001007210755现在要实现的功能是:使用SQL语句,当code = 010 时,所有city 更新为北京当code = 020 时,所有的city更新为上海 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 update chinacode ste city=if(code ='010','北京',if(code ='020','上海',code)) update chinacode set city=if(code ='010','北京',if(code ='020','上海',code)) update tbset city=(case when code=010 then 北京 when code=020 then 上海 end) update chinacode set city=(case code when '010' then '北京' when '020' then '上海' end); 大家好,这个问题问错了。是更新 范围比如我要更新 code 为 100000-20000之间的数显示上海。20000001-3000000为北京。 20000001-3000000为北京。:20001-30000?update chinacode set city=if(code between 200001 and 30000,'北京',if(code between 100000 and 200000,'上海',code)) 分开写更清晰update chinacode set city='北京' where code between 200001 and 30000;update chinacode set city='上海' where code between 100000 and 200000; update chinacode set city=(case code+0 when between 20000001 and 3000000 then '北京' when between 100000 and 20000 then '上海' end);我怀疑他的CODE字段是个字符串型的。 那里是这样呢?又要如何更新?mobile SP13123456789 联通139123456789 移动就是说跟据前三位 将SP 更新为联通或者移动这又要怎么做? update tt set SP=if(left(mobile='131','联通','移动'))OR将移动、联通头三位存入另一表中,与工作表连接替换 update tt set sp='联通' where left(mobile,3)='131';update tt set sp='移动' where left(mobile,3)='139';一贴一问。不要没完没了行么? 更正下11楼的update tt set SP=if(left(mobile,3)='131','联通','移动')) update tt set SP=if(left(mobile='131',3),'联通','移动'))OR将移动、联通头三位存入另一表中,与工作表连接替换呵呵,写掉了 update table set SP=case left(mobile,3) when 131 then '联通' when 132 '联通' when 139 then '移动' end Windows下mysql集群问题?求救! mysql导入数据变大如何压缩 AB表 求sql ubuntu mysql配置错误导致无法启动mysql,希望达人前来帮助。 提问,mysql中--log-bin类型的日志能否将使用某条语句的mysql用户名打印出来 JDBC-MySQL···· mysql 变量作用域的例子有问题吗? 在mysql里支持exists么? MYSQL数据库中需使用字符长度的问题 where 和 join on的问题 insert语句的询问! 如下问题求一条MYSQL语句
set city=(case when code=010 then 北京 when code=020 then 上海 end)
update chinacode set city=(case code when '010' then '北京' when '020' then '上海' end);
是更新 范围比如我要更新 code 为 100000-20000之间的数显示上海。
20000001-3000000为北京。
update chinacode set city=if(code between 200001 and 30000,'北京',if(code between 100000 and 200000,'上海',code))
mobile SP
13123456789 联通
139123456789 移动
就是说跟据前三位 将SP 更新为联通或者移动
这又要怎么做?
将移动、联通头三位存入另一表中,与工作表连接替换
update tt set sp='移动' where left(mobile,3)='139';一贴一问。不要没完没了行么?
update tt set SP=if(left(mobile,3)='131','联通','移动'))
将移动、联通头三位存入另一表中,与工作表连接替换呵呵,写掉了
set SP=case left(mobile,3) when 131 then '联通' when 132 '联通' when 139 then '移动' end