0

There are roughly 4000 file paths stored in the img_path column in a table called 'sunshine'.

The structure to all of these paths changed the same way.

I was wondering if it is possible to run a mySQL query that will change all current image path records, to the newly changed one, for all records in the 'sunshine' table?

Note: the only difference between the old and new path is that I need to add a sunny directory to all previous img_paths.

Current 'img_path' column:

images/a/a1.jpg images/a/a2.jpg images/a/a3.jpg 

What I am trying to accomplish:

images/sunny/a/a1.jpg images/sunny/a/a2.jpg images/sunny/a/a3.jpg 

many thanks in advance!

2
  • How about you show us your table schema (SHOW CREATE sunshine) and we can help you create a query to update the table? Commented Jan 15, 2013 at 3:00
  • 1
    see, e.g. stackoverflow.com/questions/1755408/mysql-regex-replace - you're looking for REGEXP_REPLACE. Commented Jan 15, 2013 at 3:06

1 Answer 1

4

Try this

UPDATE Sunshine SET img_paths = REPLACE(img_paths,'images/','images/sunny/'); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.