Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2002
    Posts
    86

    Unanswered: How can I compare between two tables

    Hi All,
    I am working with db2v7.2 aix , I need to compare between two tables and extract unmatched rows, could you please share your kowledage and let me know .

    Thanks

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Do the tables have a primary key or unique index (or any combination of columns that you know are unique)?
    Last edited by Marcus_A; 05-16-03 at 17:11.

  3. #3
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: How can I compare between two tables

    Something I did recently ...

    with temp(acust,bcust) as
    (select
    a.cust_id
    ,b.cust_id
    from custuser a
    full outer join
    cdt_custuser b on
    a.cust_id=b.cust_id )
    select acust,bcust from temp
    where acust is null or bcust is null ;

    Here I am assuming cust_id is a unique/primary key ... If it has more columns, you might need to have them also in your query

    HTH

    Cheers

    Sathyaram

    Originally posted by David2002
    Hi All,
    I am working with db2v7.2 aix , I need to compare between two tables and extract unmatched rows, could you please share your kowledage and let me know .

    Thanks

  4. #4
    Join Date
    Jul 2002
    Posts
    86

    Re: How can I compare between two tables

    Originally posted by sathyaram_s
    Something I did recently ...

    with temp(acust,bcust) as
    (select
    a.cust_id
    ,b.cust_id
    from custuser a
    full outer join
    cdt_custuser b on
    a.cust_id=b.cust_id )
    select acust,bcust from temp
    where acust is null or bcust is null ;

    Here I am assuming cust_id is a unique/primary key ... If it has more columns, you might need to have them also in your query

    HTH

    Cheers

    Sathyaram
    Thank you so much, It was helpfull

Posting Permissions

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