PDA

View Full Version : mysql query: concatenating onto an existing field


Jakeman
06-20-2004, 05:49 AM
Lets say I have the field table.field of type mediumtext that already contains a string value. I want to add to the value of the field by concatenating another string on the end of the existing string.

Is there a special query to do this or do I need to concatenate in PHP and then do a regular UPDATE query?

thx

Dean C
06-20-2004, 11:25 AM
I think you can use the MySQL function CONCAT. Straight from the manual:

http://dev.mysql.com/doc/mysql/en/String_functions.html

Xenon
06-20-2004, 06:48 PM
so in short:
UPDATE table SET field = CONCAT(field, 'additional string') ;)

Jakeman
06-22-2004, 03:29 AM
thx :cheeky:

Xenon
06-22-2004, 03:44 PM
you're welcome Jake :)