Home Forums SQL Server 2008 T-SQL (SS2K8) When if ever would you following a JOIN ON clause with an AND instead of WHERE? RE: When if ever would you following a JOIN ON clause with an AND instead of WHERE?

  • KoldCoffee (10/19/2014)


    ...I incremented the JOIN condition in Eirikur's LEFT JOIN example and found that the entire left table is returned, whether the JOIN condition is <1, <2, <3, <4

    SELECT

    MT.MT_ID

    ,MT.MT_DATE

    ,MT.REF_ID

    ,RF.REF_VAL

    FROM MAIN_TABLE MT

    LEFT OUTER JOIN REF RF

    ON MT.REF_ID = RF.REF_ID

    AND RF.REF_ID < 4;

    The AND is joining to only those rows in the right table that satisfy the JOIN criteria.

    I think I understand finally.

    Spot on;-)

    😎