MySQL将字符串连接到列 [英] MySQL concatenate a string to a column

查看:97
本文介绍了MySQL将字符串连接到列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过添加更多数据来连续编辑信息的内容,例如:

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'

它给了我

name       obs
charles    vegetarian
xena       otaku

我想添加到他们的观察员友好的勤奋工作者"中

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

我尝试过:

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

推荐答案

在MySQL中,加号+是用于执行算术运算的操作数.

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

您需要使用CONCAT()函数将字符串连接在一起.

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

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

这篇关于MySQL将字符串连接到列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆