Results 1 to 2 of 2

Thread: Compare 2 columns in two tables

  1. #1
    Join Date
    Jan 2004
    Posts
    7

    Compare 2 columns in two tables

    How do you compare 2 ID columns of int type of one table with that of another.
    If the combo columns of the record x of table1 matches that with any record with the same combo columns in table2, do not select the record x.

  2. #2
    Join Date
    Mar 2003
    Location
    Woking, UK
    Posts
    152
    if you want select values from table1 that don't exist in table2 you can use "NOT EXISTS" or LEFT/RIGHT/FULL [OUTER] JOIN...

    select * from table1 x where not exists (select * from table2 where a=x.a)

    select * from table1 x left outer join table2 y on y.a=x.a
    where y.a is null

    select * from table1 x right outer join table2 y on y.a=x.a
    where x.a is null

    select * from table1 x full outer join table2 y on y.a=x.a
    where x.a is null or y.a is null
    You Have To Be Happy With What You Have To Be Happy With (KC)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •