0

They return the same count of rows, but I'm not sure if one is an accident waiting to happen, or one is simply "the preferred method":

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)
NullUserException
  • 83,810
  • 28
  • 209
  • 234
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862

1 Answers1

0

So the reason there's a difference is due to the order of execution. You may not notice the difference on some table combinations, but on very large tables, you generally want to filter with the JOIN first.

This post gives some good information toward that end it looks like: Order Of Execution of the SQL query

Community
  • 1
  • 1
Jason Whitish
  • 1,428
  • 1
  • 23
  • 27
  • 2
    -1 I find it highly unlikely that the query optimizer would generate a different plan for these statements. – NullUserException Mar 08 '13 at 16:37
  • @NullUserException That's fair, given the specific query. I suppose I was thinking of it more generally. Although, really, the point you make in your comment above is the more appropriate one; that comma joins are generally a bad habit to get into regardless. – Jason Whitish Mar 08 '13 at 18:21