Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2008
    Posts
    6

    Unanswered: difference between two tables

    Hi,

    Iam looking out for difference in data between two similar tables.Since minus was not working, I tried using not exists using the following query to retrieve A-B functionality

    select * from table A a1 where not exists (select * from table B b1 where a1.key1=b1.key1 and a1.key2=b1.key2 and a1.key3=b1.key1)

    here my problem is i do not have a primary key field, but a unique combination of 3 fields.therefore, I tried the above option.

    When i execute this ...the results are wierd..im confused.

    Is there any other way i can acheive this, such that I can get records from table A which are not similar to that of table B.

    Appreciate a quick help.

    Thanks,
    Kim

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Typo? "a1.key3=b1.key1"

  3. #3
    Join Date
    Jun 2008
    Posts
    6
    Hi,

    Thanks...!!Its a typo...!!

    it should be a1.key3=b1.key3....

  4. #4
    Join Date
    Mar 2007
    Posts
    72

    query

    Try this,
    #
    select * from A where not exists (select 1 from b where a.1 = b.1 and a.2 = b.2 and a.3 = b.3)

    HTH

    suda

  5. #5
    Join Date
    May 2009
    Posts
    1

    Smile

    Hi thanks for your suggestion. It helped for me also.

Posting Permissions

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