SQL Server Performance

Query JOIN help?

Discussion in 'T-SQL Performance Tuning for Developers' started by emily2001, Sep 26, 2005.

  1. emily2001 New Member

    For each record in table A, I want to return the entire contents of
    table B. What is the most efficient way to accomplish this?


    Here are my table definitions with a few records of data:


    TABLEA
    firstName | color
    -------------------
    Person1, blue
    Person1, green
    Person2, blue


    TABLEB
    color
    --------
    blue
    green
    red


    If the color matches a color in tableB, I want to return the color,
    otherwise return a null.


    I want to return results Like this:
    Person1, blue
    Person1, green
    Person1, ''
    Person2, blue
    Person2, ''
    Person2, ''

  2. Adriaan New Member

    You're looking for a FULL JOIN - look it up in BOL (Books OnLine, installed with the SQL Server software).

Share This Page