Replace in update, change extension in filenames

Asked

Viewed 52 times

3

I have a table with images, images, in which one of these columns (file_name) has names of pictures, some jpg others png, what I need is to change, to make UPDATE all to the extension png, that is, change any extension you have and put png.

PS: there are filenames that have points beyond the extension, e.g.: "41sUhh.mGDDL.SY355.jpg"

1 answer

2


Use the replace()

update tabela set file_name = replace(file_name, '.jpg', '.png');

You just have to be careful not to have more than one occurrence of .jpg in your column caminho_foto.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.