开发者

SQL Update a field by removing a part of it

In my work, I am stuck with a SQL problem.

I have a field i开发者_运维知识库n one of my table which contains strings of the form "%_abc". I want to update this column by removing "_abc" at end of every entry. Is there a nice way to get this done using SQL?

Thanks, Anil.


update table1 set field1 = substr(field,1,length(field1)-4) where ...

HTH


If your database is ANSI SQL-92 compliant, you can use:

UPDATE myTable SET myColumn = TRIM(trailing '_abc' FROM myColumn);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜