Need help on query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kdinuk
    New Member
    • Sep 2010
    • 1

    #1

    Need help on query

    TableName: Table1
    T1 Field1 Field2
    Rows: 1 A
    2 B
    3 C
    4 C
    TableName: Table2
    Field1 Field2
    Rows: 1 A
    2 C
    3 D

    Output
    Field1 Table1.Field2 Table2.Field2
    2 B C
    3 C D

    Basically, I would like to display rows which are matching table1.field1 = table2.field1 and not matching table1.field2 = table2.field2
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Code:
    SELECT Table1.Field1, Table1.Field2, Table2.Field1, Table2.Field2
    FROM Table1 INNER JOIN Table2 ON (Table1.Field1 = Table2.Field1) AND (Table1.Field2 <> Table2.Field2);
    Its pretty much as simple as you describe it in wording, its just a matter of converting it into SQL syntax. Note that you cannot write this query in the Query GUI window, you will have to switch to direct SQL view mode, and write it.

    Comment

    Working...