开发者

query not working with empty fields on access

What is wrong in this query running on MS Access 2003 database.

It works fine if fields are not empty, but whe开发者_JS百科n any of the fields is empty it results empty string.

SELECT CustomerName,IIF(Address1="","",Address1)+IIF(Address1&
Address2="","",",")+IIF(Address2="","",Address2)+IIF(Address1&Address2&
Address3="","",",")+IIF(Address3=" "," ",Address3) AS Address FROM CustomerDetails


You can replace ="" with is null, but the output still probably is not what you want, but you really never said what you want the output to look like.

SELECT CustomerName,IIF(Address1 is null,"",Address1)+IIF(Address1& Address2 is null,"",",")+IIF(Address2 is null,"",Address2)+IIF(Address1&Address2& Address3 is null,"",",")+IIF(Address3 is null," ",Address3) AS Address FROM CustomerDetails

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜