Update to remove a piece of a varchar field

3

I have a column with a varchar field. In this column it has a value like this:

http://dominio/img//12.jpg

I want to make an update that leaves this field like this:

http://dominio/img/12.jpg

This // I want to remove always starts at a fixed position in the string.

How would I do this update?

The update is in the whole table.

    
asked by anonymous 19.05.2015 / 15:00

1 answer

2

Pretty simple, in real:

UPDATE TABELA
SET COLUNA = REPLACE(REPLACE(COLUNA, '//', '/'), 'http:/', 'http://');

I made you a Fiddle .

See more about REPLACE here .

    
19.05.2015 / 16:23