Use update statement .
eg.
table1 (tablename)
id values
1 text1
2 text2
3 text3
Let the table1 contains two fields id and value. U need to append some text
to the existing values. is it ?
ok...use the following postgresql query .
update table1 set values = values || 'newtext' where id = 1
|| --> string concat operator
This will result in
table1
id values
1 text1newtext
2 text2
3 text3
If you want to update all the rows remove the 'where' condition
Try this and reply
-somaskarthic
Quote:
Originally Posted by srkartes
I am a novice when it comes to using SQL. I would like to append text to existing data in a specified column, but I can not figure out how to do it. I was trying to use an update query, but as far as I can tell this only replaces the data within the column. Any help would be appreciated
Here i mentioned is postgresql query , if u use some other database
please find the appropriate sting concat operator . In postgres || is the concat operator . If you use mysql or sql server , please find the correct concatenation operator.
-somaskarthic
Quote:
Originally Posted by somaskarthic
Hi
Use update statement .
eg.
table1 (tablename)
id values
1 text1
2 text2
3 text3
Let the table1 contains two fields id and value. U need to append some text
to the existing values. is it ?
ok...use the following postgresql query .
update table1 set values = values || 'newtext' where id = 1
|| --> string concat operator
This will result in
table1
id values
1 text1newtext
2 text2
3 text3
If you want to update all the rows remove the 'where' condition
Try this and reply
-somaskarthic
Quote:
Originally Posted by somaskarthic
Hi
Here i mentioned is postgresql query , if u use some other database
please find the appropriate sting concat operator . In postgres || is the concat operator . If you use mysql or sql server , please find the correct concatenation operator.
-somaskarthic
This is the way:
update table1 set values = values + 'newtext' where id = 1|||Thanks guys! Worked perfectly.
No comments:
Post a Comment