Forum Moderators: coopster

Message Too Old, No Replies

mysql set help

         

BlackRaven

8:34 pm on Apr 4, 2006 (gmt 0)

10+ Year Member



wondering if anyone could help me with a simple mysql statment

currently i am using mysql set command to change the entry of the field info.
example:

UPDATE data SET
info = '$newinfo',
WHERE id='1';

what i am trying to do is maintain the old info while combining it with $newinfo. I know something can be done with numbers how about characters?

UPDATE data SET
info = info + '$newinfo',
WHERE id='1';

coopster

8:42 pm on Apr 4, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Putting strings together is called concatenation. CONCAT [dev.mysql.com] should do the trick.
UPDATE data SET 
info = CONCAT(info,'$newinfo')
WHERE id=1;

[edited by: coopster at 8:44 pm (utc) on April 4, 2006]

ChadSEO

8:44 pm on Apr 4, 2006 (gmt 0)

10+ Year Member



Blackraven,

The concat function will do what you want, like this:

UPDATE data SET
info = concat(info,'$newinfo')
WHERE id='1';

Chad