AnchovyLegend
AnchovyLegend

Reputation: 12538

Query to modify a record the same way for all rows

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!

Upvotes: 0

Views: 76

Answers (1)

rs.
rs.

Reputation: 27427

Try this

UPDATE Sunshine
SET img_paths = REPLACE(img_paths,'images/','images/sunny/');

Upvotes: 4

Related Questions