UPDATE my_table SET imageurl = CONCAT( LEFT(imageurl, LENGTH(imageurl) - INDEX( imageurl, '.jpg') ) ,'.gif'\ )