Hi!
Is it possible to update a field with some new values and to keep the old values in the same way???
For example - the old value of the field is: "123" - so now I want to add "456" - so I do the Update like
UPDATE table SET field = field + "456"
Do you get me???
Thanks in advance!
this is straight from mysql.com
If you access a column from tbl_name in an expression, UPDATE uses the current value of the column. For example, the following statement sets the age column to one more than its current value: mysql> UPDATE persondata SET age=age+1;
If you access a column from tbl_name in an expression, UPDATE uses the current value of the column. For example, the following statement sets the age column to one more than its current value:
mysql> UPDATE persondata SET age=age+1;
If you do that the field value will be 123+456=579
Originally posted by stolzyboy this is straight from mysql.com
This will not work for me, because I will have to do the matter with strings! 🙁
Originally posted by pckidcomplainer This will not work for me, because I will have to do the matter with strings! 🙁
what do you mean, you have to do the matter with strings
Originally posted by stolzyboy what do you mean, you have to do the matter with strings
I have to add some Text to a Field that contains text! I do NOT want to do some addition with numbers.
Perhaps my example with "123" was bad.
Take this one: the field contains "hello" - and I want to add "world" - so that in the end the field contains "hello world"
Got it? :rolleyes:
ok, another one from mysql.com
CONCAT(str1,str2,...) UPDATE table SET field= CONCAT('tmp_', field);
so with your example, you would do
fieldname already holds hello in this case
update tablename set fieldname = concat(fieldname, " world");
Why not use the ANSI standard concat operator || for this?
update table set field=field || 'more text';