有我一个prodcut表
breed
a
b
c
d
e
f
g
.
.
.
另一个表order
breed amount
a 5
c 3
e 2
g 8
现要求查询出结果如下
breed amount
a 5
b
c 3
d
e 2
f
g 8
.
.
.
无数据的品种一定要显示为空,请帮帮我吧,谢谢!
------解决方案--------------------
select p.breed,o.amount from [prodcut] p left join [order] o on p.breed=o.breed
------解决方案--------------------
Select prodcut.breed,T.amount
From prodcut Left outer join (Select breed,amount From [order]) T
On prodcut.breed=T.breed
------解决方案--------------------
select a.breed , isnull(b.amount , null) amount from prodcut a
left join order b on a.breed = b.breed