SQL update statement to change the value of a field and not replace it
Posted
by wzzrd
on Stack Overflow
See other posts from Stack Overflow
or by wzzrd
Published on 2010-05-18T20:40:24Z
Indexed on
2010/05/18
20:50 UTC
Read the original article
Hit count: 154
postgresql
|sql
I'm in the process of migrating some databases. I have this table that has a couple of hundred rows, and has a filename column. To each record in this table, the filename column needs to be altered and part of a path needs to be prepended to the value that is in that field.
The table is like:
| 1 | filename1 |
| 2 | filename2 |
and needs to become:
| 1 | path/filename1 |
| 2 | path/filename2 |
I am not an SQL guru, but I know the basics. This eludes me though. Is there a way to do something like:
update table
set filename = 'path/' + filename
where id = 1;
© Stack Overflow or respective owner