本文介绍了加入时变为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在我的sql中加入名字和姓氏

这是我的sql:

选择concat(FirstName,'',LastName)作为tablename的全名;

但是如果姓氏是空白的,那么我的名字就是null ...

但在这种情况下我想要名字,,,怎么做?

i have to join first name & last name in my sql
this is my sql :
select concat(FirstName,' ',LastName) as fullname from tablename;
but if last name is blank,then i am getting null as fullname..
but in that case i want first name ,,,how to do this??

推荐答案


select (Isnull(@fname,' ')+''+Isnull(@lastname,' ') ) as fullname ;  


select Trim(FirstName + ' ' + LastName) as fullname from tablename;






Or

select Trim(FirstName & ' ' & LastName) as fullname from tablename;



我不确定'+'和'&',所以请尝试两者,这将满足您的需求。


I am not sure about the '+' and '&', so try both and this will fulfill your need.


这篇关于加入时变为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 07:53