如果值不为空,我试图放入一个空格,但是当我运行查询时它似乎只输出一个数字?
CONCAT(address, IF(address2 = '', '', ' ' & address2), ' ', city, ', ', state, ' ', zip) AS theAddress
以上的查询输出是:
1234 N. Shore Ave.0 Burbank, CA 41577
输出应如下所示:
1234 N. Shore Ave. Apartment 223 Burbank, CA 41577
我在这里做错了什么?
答案 0 :(得分:4)
试试这个:
CONCAT(address, IF(address2 = '', '', CONCAT(' ', address2)), ' ', city, ', ', state, ' ', zip) AS theAddress
我认为你的代码正在做的是空格和地址2之间的逻辑AND
答案 1 :(得分:2)
我认为它应该是另一个concat
而不是&
CONCAT(address, IF(address2 = '', '', CONCAT(' ', address2)), ' ', city, ', ', state, ' ', zip) AS theAddress
^ here
' ' & address2
返回0和1(真或假)