开发者

MySQL populating a new field from parts of existing fields

开发者 https://www.devze.com 2023-02-13 01:10 出处:网络
I have a few fields holding paths to images.I now want to add another field holding the image name.How can I extract the file name from the full path from another field and update the name into th开发

I have a few fields holding paths to images. I now want to add another field holding the image name. How can I extract the file name from the full path from another field and update the name into th开发者_运维百科e new field?

this is how i want it to look:

fields:

image_thumbnail | image_name

values:

http://mysite.com/images/thumbnail/1234.jpg | 1234.jpg

note: image names may have different file extensions


UPDATE your_table
   SET image_name = SUBSTRING_INDEX(image_thumbnail, '/', -1)
     ;
0

精彩评论

暂无评论...
验证码 换一张
取 消