Results 1 to 4 of 4
  1. #1
    mkc80 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    56

    Comparison Query

    I need to build a query where I can output only the columns which do not match in two different tables A and B (which contain same number of columns and similar information)


    For example table A and B both have 10 columns with same 3 primary keys.
    (Reason for doing this is to find data entry errors in either table A or B)

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    Tables are 'similar' - how are they different?

    What are you looking for - errors in primary keys? Did you try Find Unmatched query?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    mkc80 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    56
    Not errors in primary keys. Data entry errors in the remaining 7 columns. Structure of the two tables is exactly the same.

    For example table A has the values:
    A B C 1 2 3 4 5 6 7 (this is one row, A B C are the values for primary keys)
    Table B has the values
    A B C 1 2 3 4 5 6 8 (this is one row, A B C are the values for primary keys)

    As you can see the 10th column has different values (7 in table A, 8 in table B).
    The result of the query should be Columns 1,2,3 & 10, along with the values in table B.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    So the same primary key values are in both tables - i.e. the same values and same number of records so there is a one-to-one relationship?

    Create a query that joins the two tables on the 3 keys. Pull in the fields from both tables then create 7 fields with expressions like:
    Col1: TableA.fieldname1=TableB.fieldname1
    Then in criteria row under each constructed field: =False
    Put each criteria on a separate row so get stair-step effect and the OR operator is used.
    These constructed fields can be not visible by unchecking Show row.

    Records where any field pair does not match will be returned. You will have to see all the native fields. Arrange to display the pairs together so you can examine the variances.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Comparison Query
    By mkc80 in forum Access
    Replies: 3
    Last Post: 08-11-2012, 04:50 PM
  2. Comparison
    By raytackettsells in forum Queries
    Replies: 2
    Last Post: 08-06-2012, 05:30 PM
  3. Number comparison help
    By kgriff in forum Access
    Replies: 13
    Last Post: 02-17-2012, 07:41 PM
  4. Help: Comparison query to find non-matches
    By 14erclimber in forum Queries
    Replies: 6
    Last Post: 06-09-2010, 09:29 AM
  5. Comparison
    By VICTOR HUGO in forum Access
    Replies: 8
    Last Post: 02-10-2010, 04:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums