Reputation: 75
I am trying to update the data in a particular column according to the data in another column.
Some thing like below.
Name ImageName
---------- -----------
aaa no_image.jpg
bbb no_image.jpg
ccc no_image.jpg
ddd no_image.jpg
I like to update this table something like below.
Name ImageName
---------- -----------
aaa aaa.jpg
bbb bbb.jpg
ccc ccc.jpg
ddd ddd.jpg
Please find the sqlfiddle from the following link.
SqlFiddle Link
Upvotes: 0
Views: 44
Reputation: 68
Actually i think you need to put where statement because some columns might already have image name update images t set t.image_name=t.name||'.jpg' where t.image_name='no_image.jpg'
Upvotes: 0
Reputation: 57381
update table1 set ImageName=concat(Name,substr(ImageName, instr(ImageName,'.')));
Upvotes: 2
Reputation: 18747
You could simply do this in an UPDATE
query itself.
Try this:
UPDATE table1
SET ImageName=Name+'.jpg'
Upvotes: 3