webchun
webchun

Reputation: 1214

Insert text in each row of mysql field

I have a table with this structure :

ID | IMG
_____________
1  | img.jpg
2  | otherimg.png
3  | img2.png 
4  | someimg.gif
5  | otherelseimg.jpg
6  | dummy.jpg
7  | jusimg.jpg

How can I modified each row to become like this :

ID | IMG
_____________
1  | folder/img.jpg
2  | folder/otherimg.png
3  | folder/img2.png 
4  | folder/someimg.gif
5  | folder/otherelseimg.jpg
6  | folder/dummy.jpg
7  | folder/jusimg.jpg

Upvotes: 0

Views: 363

Answers (2)

John Woo
John Woo

Reputation: 263943

use CONCAT since you are using MySQL.

UPDATE tableName
SET    IMG = CONCAT('folder/', IMG)

Upvotes: 1

Joe G Joseph
Joe G Joseph

Reputation: 24116

you can use CONCAT() function in mysql. which is used to concatenate two or more strings

update <table>
set IMG=concat('folder/',IMG)

SQL fiddle demo

Upvotes: 1

Related Questions