我使用SQL Server 2008的條件在on子句
請告訴我之間的區別在於:
隨着Where
條款
select customer.Id,
order.Id
from Customer customer
left outer join Order order on order.customerId = customer.Id
where
order.deleted =0
在條件隨着條件對ON
條款
select customer.Id,
order.Id
from Customer customer
left outer join Order order
on order.customerId = customer.Id
and order.deleted =0
那麼兩者如何與
select customer.Id,
order.Id
from Customer customer
inner join Order order on order.customerId = customer.Id
where
order.deleted =0
與指定「WHERE」(只要它適用於該連接表)的區別沒有區別。然後你使用一個'INNER JOIN'來返回兩個表的匹配。一個'LEFT OUTER JOIN'將返回左表,以及右表的匹配或不匹配('NULL')結果。 – Kermit