Select a.ID,b.Name as Pserson1Name,c.Name as Pserson2Name
,d.Name as Pserson3Name
from 表B as a inner join 表A as b on b.ID=a.Person1ID
inner join 表A as c on c.ID=a.Person2ID
inner join 表A as d on d.ID=a.Person3ID
select b.ID ,Pserson1Name=case when Person1ID=1 then '张三' end,
Person2Name=case when Person2ID=2 then '李四' end,
Person3Name=case when Person3ID=2 then '王二' end
from 表B b join 表A a on a.id=b.id
select b.ID ,Pserson1Name=case when Person1ID=1 then '张三' end,
Person2Name=case when Person2ID=2 then '李四' end,
Person3Name=case when Person3ID=3 then '王二' end
from 表B b join 表A a on a.id=b.id
Select a.ID,
Pserson1Name=(select top 1 name from 表A where id=b.Person1ID),
Pserson2Name=(select top 1 name from 表A where id=b.Person2ID),
Pserson3Name=(select top 1 name from 表A where id=b.Person3ID)
from 表B b