create table #table1 (a varchar(10),b varchar(10),c varchar(10)) create table #table2 (a varchar(10),b varchar(10),c varchar(10))insert into #table1 select 'a','b','c' union select 'e','f','g' union select 'a','czx','zxc' union select 'acxz','cxz','cxz' insert into #table2 select 'ab','b','c' union select 'ef','f','g' union select 'aczx','czx','zxc' union select 'acxz','cxz','cxz'select * from #table1 as a left join #table2 as b on a.a+a.b=b.a
你的shpo字段都是NULL,任何字符和NULL想加都是NULL。
NULL和‘’ 不是同一个概念
create table #table2 (a varchar(10),b varchar(10),c varchar(10))insert into #table1
select 'a','b','c'
union
select 'e','f','g'
union
select 'a','czx','zxc'
union
select 'acxz','cxz','cxz'
insert into #table2
select 'ab','b','c'
union
select 'ef','f','g'
union
select 'aczx','czx','zxc'
union
select 'acxz','cxz','cxz'select * from #table1 as a
left join #table2 as b on a.a+a.b=b.a
写法好麻烦。。
你可以把 列 加上 isnull(列名,'') 这样就会自动把null转为''