adding information onto the end of a value in a field

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
DynamiteHost
Forum Commoner
Posts: 69
Joined: Sat Aug 10, 2002 5:33 pm

adding information onto the end of a value in a field

Post by DynamiteHost »

hi,

say if i had fieldname and fieldname contained "value", i want to keep "value" and add ",value2" on to it.

would I have to select the information and put it into the new value or is there anyother quicker method?
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

yep, use the CONCAT_WS function: http://www.mysql.com/doc/en/String_func ... ml#IDX1163

Code: Select all

CONCAT_WS(",", column_value, "value2")
just use that as the value you want to insert/update

Code: Select all

INSERT INTO table SET column_name=CONCAT_WS(",", column_name, "value2")
i haven't tested this but according to the manual it should work.
Post Reply