Home Forums SQL Server 2008 T-SQL (SS2K8) Table Join using unique values or where Null = all values RE: Table Join using unique values or where Null = all values

  • Hi There

    I think it would be better if you could provide us the format of output required.

    Anyway try this:

    SELECT A.Area, B.DeliveryName, A.Item, A.Description

    FROM

    TableA A inner join TableB B ON (A.Area = B.ColId) or (A.Area is NULL)

    order by A.Area desc

    Output:

    ---------

    AreaDeliveryNameItemDescription

    A4Acme4B4352Whatits

    A1Acme1B1232Thingymebobs

    NULLAcme1B8769Dunno

    NULLAcme4B8769Dunno

    NULLAcme8B8769Dunno

    NULLAcme9B8769Dunno

    Not sure if this is what you need ! 🙂