select t1.* ,isnull(t2.数字,0) 数字 from a t1 left join b t2 on t1.姓 = t2.姓
select a.*,isnull(b.数字,0) from a t1 left join b t2 on t1.姓 = t2.姓
select t1.*,isnull(b.数字,0) from a t1 left join b t2 on t1.姓 = t2.姓
create table #a(A varchar(20),Name varchar(30)) create table #b(Name varchar(30),score int) insert into #a(a,name) select 'AA','张' union all select 'BB', '李' union all select 'CC', '王' union all select 'DD', '杨' insert into #b(name,score) select '张',100 union all select '李',200 select a.a,a.Name,isnull(b.score,0) score from #a A left join #b B on a.Name=b.Name
select t1.* ,isnull(t2.数字,0) 数字
from a t1
left join b t2 on t1.姓 = t2.姓
create table #b(Name varchar(30),score int)
insert into #a(a,name)
select 'AA','张'
union all select
'BB', '李'
union all select
'CC', '王'
union all select
'DD', '杨'
insert into #b(name,score)
select '张',100
union all select
'李',200 select a.a,a.Name,isnull(b.score,0) score from #a A left join #b B on a.Name=b.Name