开发者

Update colum with value from another column + text

开发者 https://www.devze.com 2023-02-02 00:49 出处:网络
I imported an e-store\'s database values into my own, and it mostly worked out fine. However, there were no image file names. So, I need to updat开发者_运维问答e the entire database- over 6,000 record

I imported an e-store's database values into my own, and it mostly worked out fine. However, there were no image file names. So, I need to updat开发者_运维问答e the entire database- over 6,000 records, so that under 'image' we get a path + model name + jpg, so each product can be associated with an image. Im having trouble mixing the dynamic column value with the static path. Here is what I need to accomplish:

UPDATE `store`.`pr_product` 
SET `image` = 'data/products/`**model_no**`.jpg' 
WHERE `pr_product`.`product_id` = `pr_product`.`product_id` ;

But cannot get it to recognize the dynamic nature of 'model_no'

Thanks in advance


Max,

Please what you means about dynamic nature of 'model_no'? Is this column's datatype int or long or varchar

Please need more explaination with example

you can test the following if e.g model_no is column in pr_product table

UPDATE store.pr_product 
SET image = 'data/products/'+pr_product.model_no+'.jpg' 
WHERE pr_product.product_id = pr_product.product_id ;

Best Regards,

Mohammed Thabet Zaky

0

精彩评论

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