User Profile

Collapse

Profile Sidebar

Collapse
PNair
PNair
Last Activity: Dec 31 '13, 03:06 PM
Joined: Dec 26 '13
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • PNair
    replied to Compare two tables field by field
    Here is my query. I had to make some edits to remove the table name and field name, but the structure is same.

    As you can see, I am doing a SELECT *, which will give me all rows which has a mismatch. I cannot know which of the 3 conditions failed.


    Code:
    SELECT * 
    FROM   TABLE1 PD 
           INNER JOIN TABLE2 PM 
                   ON PM.KEY = PD.KEY 
    WHERE  PM.FIELD1 <> PD.FIELD1 
        OR PM.FIELD2
    ...
    See more | Go to post
    Last edited by Rabbit; Dec 27 '13, 05:09 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.

    Leave a comment:


  • PNair
    replied to Compare two tables field by field
    Thanks for the quick response. I will research on UNION and figure out how to use it. Meanwhile, if you have a sample query, could you pls share? Or makeup a simple SQL with one field. that would help.

    Thanks again,
    See more | Go to post

    Leave a comment:


  • PNair
    replied to Compare two tables field by field
    I tried that, but if i do that, i will not know which row or which field has the mismatch, unless i got line by line. Let me try to explain with the example below:

    Table1 Fld 1 Fld 2 Fld 3
    Key 1 A B C
    Key 2 A B C
    Key 3 A B C

    Table2 Fld 1 Fld 2 Fld 3
    Key 1 A X C
    Key 2 A B Y
    Key 3 A B Z

    The output I am looking for is something like this:

    Key1, Field2, B, X
    ...
    See more | Go to post

    Leave a comment:


  • PNair
    started a topic Compare two tables field by field

    Compare two tables field by field

    Hi,
    i need to compare two tables, field-by-field. The matching will be based on a key field, and the comparison will be for the non-key fields. If there is a mismatch, the key fields, along with the mismatch value (like-> Key, table1.field, table2.field)

    can this be done using SQL? Or do we need to write any programs for this?

    GP
    See more | Go to post
No activity results to display
Show More
Working...