Fero
Fero

Reputation: 13315

how to update a field which contains data using mysql

I need to update a field which contains data.

For ex:

id     fieldName
1         1,2

Now, I am getting 3,4 as another result which should be updated in id 1. That is now my result should be,

id     fieldName
1       1,2,3,4

How can this be done using mysql.

Thanks in advance.

Upvotes: 0

Views: 91

Answers (3)

YoK
YoK

Reputation: 14505

Following should do the trick:

UPDATE tablename SET columnname=concat(columnname,' my extra text');

Upvotes: 1

update TableName set fieldName = CONCAT(fieldName, '3,4') where id = 1;

Upvotes: 2

thevilledev
thevilledev

Reputation: 2377

By using UPDATE of course:

 UPDATE TABLENAME
 SET fieldName = "1,2,3,4"
 WHERE id = 1;

Assuming that fieldName is a string.

Upvotes: -1

Related Questions