left join语句中条件不同位置对结果的影响
以下两种写法:
SELECT a.*,b.id FROM [SH_StoreHouseBillDetail] a
LEFT JOIN [SH_StoreHouseBill] b ON a.[StoreHouseBillID] =b.[ID] AND b.[BuyBillID]<>0
SELECT a.*,b.id FROM [SH_StoreHouseBillDetail] a
LEFT JOIN [SH_StoreHouseBill] b ON a.[StoreHouseBillID] =b.[ID]
where b.[BuyBillID]<>0
写在where中,会有可能使得结果集的数量比sh_storehousebilldetail的数量还小