[英]PHP - Issue update db field with add to existing value
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
说我想通过添加
" add"
来更新字段name
和text
,所以字段的值现在是b add
I try use query : mysql_query("update table set text=text+' add' where name='a' ");
我尝试使用查询:
mysql_query("update table set text=text+' add' where name='a' ");
Can you analyze this issue? 你能分析这个问题吗?
Thanks in advance. 提前致谢。
使用CONCAT函数连接字符串:
mysql_query("update table set text = CONCAT(text, ' add') where name='a' ");
Using the CONCAT()
method: 使用
CONCAT()
方法:
UPDATE table SET text = CONCAT(text, ' add') WHERE name = 'a'
The following should also work: 以下内容也应该起作用:
UPDATE table SET text = text ' add' WHERE name = 'a'
尝试使用MySQL CONCAT函数
mysql_query("update table set text=concat(text, ' add') where name='a' ");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.