0

我只需要替换 SQL DB 中的尾随字符串。数据库目前有这个:

Sony Co
Coca Cola
Coke
Sony Company

我们需要从索尼系列中删除“Co”

所以输出看起来像这样:

Sony
Coca Cola
Coke
Sony Company

任何帮助表示赞赏,在此先感谢!

4

2 回答 2

3

怎么样:

select (case when name like '% CO' then left(name, len(name) - 3)
             else name
        end) as newname

注意:您没有指定数据库。在某些数据库中,len()is length(),您将使用substr()orsubstring()代替left().

于 2013-11-04T02:12:53.290 回答
0

UPDATE urtablename SET name = replace(name , 'Co', '') where name like N'%Co'

于 2013-11-04T06:34:45.050 回答