Not Equal To

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patelaashish
    New Member
    • Oct 2006
    • 26

    #1

    Not Equal To

    Hi,

    i have two tables with column names in the bracket below:
    TABLE 1(A,B,C)
    TABLE 2(A,D,E,F)

    Column A in both the tables is common.
    I need a query in MS SQL which shows me results in which TABLE2.A != TABLE1.A?. I tried it but it shows loads of duplicate TABLE2.A columns.


    I hope it makes sense.

    Thanks,

    Aash.
  • rharvieuxsql
    New Member
    • Nov 2006
    • 9

    #2
    --Try this:

    SELECT distinct *
    FROM table2
    WHERE NOT EXISTS (SELECT * FROM table1 WHERE table1.a = table2.a)

    SELECT *
    FROM table2
    WHERE NOT EXISTS (SELECT * FROM table1 WHERE table1.a = table2.a)

    Comment

    • azizul
      New Member
      • Apr 2008
      • 1

      #3
      thanks...your sql statement is very helpful...


      Originally posted by rharvieuxsql
      --Try this:

      SELECT distinct *
      FROM table2
      WHERE NOT EXISTS (SELECT * FROM table1 WHERE table1.a = table2.a)

      SELECT *
      FROM table2
      WHERE NOT EXISTS (SELECT * FROM table1 WHERE table1.a = table2.a)

      Comment

      Working...