为什么这两种查询会得到不同的结果?
SQl Server的Northwind数据库下对Orders表和Customers表做左连接,对于以下两种查询方法
1. select *
from (select a.customerid x,b.orderid,b.customerid y
from Customers a,Orders b
where a.customerid*=b.customerid) c
where c.y is null
结果:
orderid x y
ALFKI NULL NULL
ANATR NULL NULL
ANTON NULL NULL
AROUT NULL NULL
BERGS NULL NULL
BLAUS NULL NULL
................... 共91行
2.select a.customerid x,b.orderid,b.customerid y
into #temp
from Customers a,Orders b
where a.customerid*=b.customerid
select * from #temp where y is null
结果:
orderid x y
PARIS NULL NULL
FISSA NULL NULL 共2行
我的目的是要检索出没下过定单的Customer,
请问这两种查询为什么会得到截然不同的结果?