5

I have the following string in an Oracle 9i database:

A,B,C,

I need to replace all instances of ',' when it is the last item in the string. I have come up with the following statement but it deletes everything in the field not just the comma. Any suggestions?

UPDATE table SET column = REPLACE(SUBSTR(column, -1, 1), ',', '');
4

4 に答える 4

8

rtrim(column, ',')効率的ではるかに短い

于 2015-01-14T12:48:07.197 に答える
1

クエリで「列」を 1 回だけ参照する場合は、次のようにします。

UPDATE table SET column = REVERSE(SUBSTR(REVERSE(column), 2));

于 2014-12-17T08:50:01.070 に答える