34,587
社区成员
发帖
与我相关
我的任务
分享
--测试数据
if not object_id(N'Tempdb..#A') is null
drop table #A
Go
Create table #A([编号] int,[姓名] nvarchar(21))
Insert #A
select 1,N'王' union all
select 2,N'张' union all
select 3,N'刘'
GO
if not object_id(N'Tempdb..#B') is null
drop table #B
Go
Create table #B([任务] nvarchar(21),[人员编号] int)
Insert #B
select N'a',1 union all
select N'b',2 union all
select N'c',2 union all
select N'd',NULL
Go
--测试数据结束
SELECT 任务,
姓名
FROM #B
LEFT JOIN #A
ON 编号 = 人员编号;