[英]Update/Adding New Value in the row mysql with php
I want to add a value (varchar) to an existing mysql table, for example I have a table like below 我想向现有的mysql表中添加一个值(varchar),例如我有一个如下表
----------------
| id | value |
| 01 | aa |
----------------
I want to create the table above as the table below 我想将上面的表格创建为下面的表格
----------------
| id | value |
| 01 | aabb |
----------------
as you can see, that I want to add the "bb" value in the "aa" table, but I have tried to use the code below but it did not work 如您所见,我想在“ aa”表中添加“ bb”值,但是我尝试使用下面的代码,但是没有用
mysql_query("UPDATE my_table SET value=value+'$newValue' WHERE id= '01'");
when I use the above code, the results I get differ from what I want 当我使用上面的代码时,我得到的结果与我想要的结果不同
how to fix this problem? 如何解决这个问题?
SET value=concat(value,'$newValue');
这就是它的工作方式,您不能通过+
添加字符串,请使用concat添加字符串。
尝试这个:
UPDATE my_table SET value = CONCAT(value, 'bb') WHERE id = 01
您可以使用MySQL函数CONCAT()执行此操作:
mysql_query("UPDATE my_table SET value=CONCAT(value, '$newValue') WHERE id= '01'");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.