Joins

  • I'd like to join on two tables, this should be easy right, but I'm getting multiple results.

    What I want to see are all the records from table A and only the matching records columns from table B. But I end up with multiple records.

    For example;

    In Table A

    record

    column1 ='3ABB'

    column 2 ='7'

    In Table B

    I have three records that match on Table A where the column1='3ABB'

    but I want to streamline the selection based on other criteria in Table B

    substring (column4,1,1)='1'

    which means I should only see one record, but I see multiple records of the same value

    I would also like to all see the records from Table A even if they are not in Table B, but with null values in the criteria columns?

    What is the correct way in coding this?

  • Sounds like you need a LEFT join. That will return all from A and only those that match from B.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • thanks

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply