【发布时间】:2014-06-20 20:13:29
【问题描述】:
我正在尝试执行以下代码...
select a.name, a.phone, b.mobile, b.relation,
case
when a.phone<>'' and b.mobile<>'' then a.phone + ' ' + b.mobile
when a.phone<>'' and b.mobile='' then a.phone
when a.phone='' and b.mobile<>'' then b.mobile
else ''
end as phone
from abc a join bcdb where a.id=b.id and b.relation='a123'
但是在执行第一种情况时,这些值是相加的,而不是被连接的……你能指导我吗
【问题讨论】:
-
当我使用两个管道符号 (||) 时出现错误..
-
列有哪些数据类型,您的 RDBMS - SQL Server、MySQL 是什么?
-
发布您在问题中收到的错误。
-
你的sql server版本?
-
如果您想将数字(int、bigint 等)值与字符串连接,您必须转换或转换它们:technet.microsoft.com/en-us/library/aa276862%28v=sql.80%29.aspx
标签: mysql sql concatenation