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);
精彩评论