sql--如何更新一个字段中指定的值。

来源:百度知道 编辑:UC知道 时间:2024/09/28 10:47:08
sql--如何更新一个字段中指定的值。
在country 字段中,所有包含en的值改成cn,如en_shanghai改成cn_shanghai,这样的SQL怎么写?
谢谢!@

update 表 set country = replace(country,'en','cn')

如果en的位置固定的话:
update 表1 set country = 'cn'+mid(country,3)
where left(country,2)='en';

如果en的位置不固定但只包含1个的话也可以,但嵌套函数多,执行慢

update tablename set fieldname = newValue where fieldName=OldValue