Reputation: 81
I have db field say like this : For example, lets say we have table like this
+--------------+
| some_table |
+--------------+
| name | text |
+--------------+
| a | b |
+--------------+
I want to update without delete existing value. say i want to update field name
and text
with adding " add"
, so value of field now is b add
I try use query : mysql_query("update table set text=text+' add' where name='a' ");
Can you analyze this issue?
Thanks in advance.
Upvotes: 1
Views: 318
Reputation: 8572
Using the CONCAT()
method:
UPDATE table SET text = CONCAT(text, ' add') WHERE name = 'a'
The following should also work:
UPDATE table SET text = text ' add' WHERE name = 'a'
Upvotes: 1
Reputation: 18569
Try to use MySQL CONCAT function
mysql_query("update table set text=concat(text, ' add') where name='a' ");
Upvotes: 0
Reputation: 2156
COncatenate strings with CONCAT function:
mysql_query("update table set text = CONCAT(text, ' add') where name='a' ");
Upvotes: 1