Fadzy
Fadzy

Reputation: 37

Mysql rename JPG to jpg

I'm switching from a windows server to a linux server and case sensitivity is a bit of a problem in the database. For most fields I've just been able to use the following command:

UPDATE images_T SET image_path = LOWER(image_path)

However for one of the fields I need to change just the JPG part to jpg and keep all other capitalization. Eg. \images\T\12435.JPG I want to change to \images\T\12435.jpg so I want to keep the capital T. I've tried using the RIGHT function to do this but haven't had much luck.

Upvotes: 1

Views: 134

Answers (3)

manji
manji

Reputation: 47978

UPDATE images_T SET image_path = REPLACE(image_path, '.JPG', '.jpg')

With LEFT+Right (works with any extension):

UPDATE images_T SET image_path = CONCAT(
                                   LEFT(image_path, length(image_path - 3))
                                 , lower(RIGHT(image_path, 3))
                                 )

Upvotes: 4

Rasika
Rasika

Reputation: 1998

Try REPLACE

Upvotes: 0

eagle12
eagle12

Reputation: 1668

You can try this

UPDATE images_T set image_path = replace(image_path,'.JPG','.jpg');

Upvotes: 0

Related Questions