user1920062
user1920062

Reputation: 339

MySQL concatenate a string to a column

What I'm trying to do its edit the information from a row adding more data, for example:

select name, obs from users where area='it'

It gives me:

name       obs
charles    vegetarian
xena       otaku

and I want to add to the their obs 'friendly hard worker'

I have tried:

update users set obs=obs+' frienly hard worker' where area='it'

but it didn't work, the result that I want is:

name       obs
charles    vegetarian frienly hard worker
xena       otaku frienly hard worker

Upvotes: 20

Views: 47048

Answers (2)

Ali Elsayed Salem
Ali Elsayed Salem

Reputation: 87

update users set obs= CONCAT('string1', column1 , 'string2', column1 , 'string3' ) where area='it'

Upvotes: 3

Blaise Swanwick
Blaise Swanwick

Reputation: 1755

In MySQL, the plus sign + is an operand for performing arithmetic operations.

You need to use the CONCAT() function to concatenate strings together.

UPDATE users 
SET obs = CONCAT(obs,' frienly hard worker') 
WHERE area='it';

Upvotes: 53

Related Questions