这两个SQL语句是否相同?

时间:2013-03-08 16:32:22

标签: sql ms-access sql-server-ce inner-join

他们返回相同的行数,但我不确定是否有一个等待发生的事故,或者一个只是“首选方法”:

SELECT duckbill.id, duckbill.pack_size, duckbill.description, duckbill.platypus_id, duckbill.department, duckbill.subdepartment, duckbill.unit_cost, duckbill.unit_list, duckbill.open_qty, duckbill.UPC_code, duckbill.UPC_pack_size, duckbill.crv_id, duckbill_platypuss.platypus_item 
FROM duckbill 
INNER JOIN duckbill_platypuss ON duckbill.platypus_id = duckbill_platypuss.platypus_id

SELECT duckbill.id, duckbill.pack_size, duckbill.description, duckbill.platypus_id, duckbill.department, duckbill.subdepartment, duckbill.unit_cost, duckbill.unit_list, duckbill.open_qty, duckbill.UPC_code, duckbill.UPC_pack_size, duckbill.crv_id, duckbill_platypuss.platypus_item
FROM duckbill, duckbill_platypuss
WHERE (duckbill.platypus_id = duckbill_platypuss.platypus_id)

1 个答案:

答案 0 :(得分:0)

因此存在差异的原因是由于执行顺序。您可能没有注意到某些表组合的差异,但在非常大的表上,您通常希望首先使用JOIN进行过滤。

这篇文章为此提供了一些好的信息:Order Of Execution of the SQL query