Conditions in LEFT JOIN (OUTER JOIN) vs INNER JOIN

前端 未结 3 785
一向
一向 2020-12-11 11:15
SELECT A.COL1, B.COL1,C.COL1
FROM TABLEA A
LEFT JOIN TABLEB B ON A.COL1 = B.COL1
LEFT JOIN TABLEC C ON (
        C.COL3 IS NOT NULL
        AND (
              C.COL         


        
3条回答
  •  无人及你
    2020-12-11 11:35

    With an OUTER JOIN your C may be NULL because there is no match for A.COL1.

    If that's the case then there can never be C.COL2 = 664 meaning any WHERE statement would throw away the row.

    By putting the condition into the ON clause you are asking that to be applied to the JOIN condition, not as a filter on the result.

    For non-outer joins it makes no difference.

提交回复
热议问题