One thought on “MySQL replace() function”

  1. another good one is

    concat()

    eg

    update [tablename] set [field_name1] = concat([field_name1],[fieldname2])

    useful if you have to make keywords or descriptions from other fields

    also useful is trim()
    eg

    select trim(trailing ‘.png’ from [field_name]) will get the image name without the .png on the end too, so you can do

    update [tablename] set [field_name2] = trim(trailing ‘.png’ from [table_name])

    very useful if importing images somewhere and you have 3 cols of images, small, med and large, etc and all have the same name, just with an _sm etc on the end

    that one would be

    update [tablename] set [field_name2] = concat(trim(trailing ‘.png’ from [table_name]),’_sm.png’)

    then you end up making

    image_sm.png in field2 from image.png in field 1

Leave a Reply

Your email address will not be published. Required fields are marked *