难解的SqlServer问题
有两表
aID aName
1 hehe
2 haha
3 xixi
b表
bID bName aID
1 bbbb 1
2 cccc 1
3 dddd 2
我想把a表的数据全部提取
加上b表的对应aID的第一
列数
如
aID aName bID bName aID
1 hehe 1 bbbb 1
2 haha 3 dddd 2
3 xixi null null null
能实现吗?
能实现吗?
[解决办法]
Select * From A
Left Join
(Select b.* From b Inner Join (Select aID, Min(bID) As bID From b Group By aID) c On b.aID = c.aID And b.bID = c.bID) D
On A.aID = D.aID