JasonDavis
JasonDavis

Reputation: 48943

Append MySQL field to the end of another field with some text as well

I have 50,000 records where I need to update a MySQL description column appending the value of a custom_size column and some text to the end of all the description columns.

My MySQL Table

UPDATE `d1_designs`
SET `description`= :description

description needs custom_size appended to it along with text

OLD_DESCRIPTION_VALUE_HERE- Old custom_size Value =VALUE OF CUSTOM_SIZE HERE

Can this be done with concat() and if so what format?

Upvotes: 1

Views: 24

Answers (1)

luksch
luksch

Reputation: 11712

You can use the old value as if was a variable in the assignment:

UPDATE d1_designs
SET description = CONCAT("blah ", d1_designs.description, " MoRe StuFf");

You can also use any other field name on the right side of the SET:

UPDATE d1_designs
SET description = CONCAT_WS(" ", description, custom_size);

Upvotes: 1

Related Questions