mysql字符串连接返回0 [英] mysql string concatenation returns 0

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

问题描述

im试图将选择查询中的3列连接起来,以在结果中显示一列.该列称为DelPostalName,由于某种原因,当我运行选择查询时,总显示为"0".就像它试图将字符串加起来一样,但是没有实际的数字要添加.香港专业教育学院一直在搜索字符串连接,这似乎是正确的语法.有任何想法吗?

im trying to concatenate 3 columns in a select query to show in one column in the results. the column is called DelPostalName and for some reason always shows a '0' when i run the select query. like its trying to add up the strings but theres not actual numbers to add. ive been googling string concatenation and this seems to be the correct syntax. any ideas?


isc_orders.ordShipFirstName + ' ' + isc_orders.ordshiplastname + isc_orders.ordshipcompany as DelPostalName,

推荐答案

由于您试图算术地将字符串彼此相加,因此结果显示为零.

The result appears as zero since you are trying to arithmetically add the strings to each other.

在MySQL中串联字符串的正确方法是使用CONCAT(str1, str2, str3)函数.

The correct method for concatenating strings in MySQL is using the CONCAT(str1, str2, str3) function.

此处是该手册功能.

PS:如果要与分隔符连接,请使用CONCAT_WS()-也在同一手册中

PS: if you want to concate with a seperator use CONCAT_WS() - also in the same manual

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

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