0

I want to update image path in MySQL table. Table schema is this:

table_brands - brand_id, brand_name, brand_image_path

Currently path is stored as-

`images/1.png`
`images/2.png`

I want to make it as

 `images/brands/1.png`
 `images/brands/2.png`

Also for some entries path is stored as

 `images/brands/1.png`
 `images/brands/2.png`

so changes should not be done for such entries.

Can someone help me?

1 Answer 1

1

You can use replace function for this purpose only for the image paths that don't contain 'brand'

 UPDATE table_brand
 SET brand_image_path = REPLACE(brand_image_path, 'images', 'images/brands')
 WHERE brand_image_path NOT LIKE '%brands%';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.