Quote:
Originally Posted by BettingSherlock
my logic says ...
|
i am sorry to have to tell you this, but your logic is wrong
inner joins return only those rows which satisfy the join conditions
the efficiency of this is determined by the database optimizer, but efficiency is not germane to the issue of which rows to return
so inner joins return only those rows which satisfy the join conditions
this would lead you to suspect that outer joins return some rows which don't satisfy the join conditions, and this is exactly what happens -- some of the rows returned are "outside" of the rows which satisfy the join conditions
in a LEFT OUTER JOIN, these "outer" rows come from the left table, and in a RIGHT OUTER JOIN these "outer" rows come from the right table
to put this a slightly different way, a LEFT OUTER JOIN returns all rows of the left table,
whether or not there is a matching row from the right table, where "matching" means that they satisfy the join conditions
and none of this has to do with efficiency
okay, so in your example, the left table of the join is the subquery which finds the maximum per group, and the right table is the actual table itself
there cannot possibly be a row in the left table (the subquery) which doesn't match a row from the right table
therefore it should be an INNER JOIN
