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

    SQL query with NULL Value Comparison in MS Access

    I am trying to compare two tables and output results where a column in table1 and the same column in table2 are not equal.

    The query looks like this:

    Select Table1.Column1, Table1.Column2, Table1.Column3, Table1.Column4 from Table1 INNER JOIN Table2 ON
    Table1.Column1 = Table2.Column1 AND Table1.Column2 = Table2.Column2 AND Table1.Column3 = Table2.Column3 WHERE
    Table1.Column4 <> Table2.Column4;

    Column1, Column2, Column3 together form the primary key for the two tables.

    When Column4 has missing values (null), the corresponding record is not showing up as a mismatch in the resulting output.

    (This is happening with other columns as well, be it Text or Number or Date/Time data type)



    Any Comments?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,597
    Try handling the nulls with Nz function:
    WHERE Nz(Table1.Column4) <> Nz(Table2.Column4);
    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 Queries
    Replies: 3
    Last Post: 08-15-2012, 01:48 PM
  2. Comparison Query
    By mkc80 in forum Access
    Replies: 3
    Last Post: 08-11-2012, 04:50 PM
  3. Replies: 1
    Last Post: 02-23-2012, 02:27 PM
  4. Access Min Max Comparison Yielding Incorrect Results
    By MetalCheese in forum Programming
    Replies: 6
    Last Post: 12-06-2011, 04:29 PM
  5. Help: Comparison query to find non-matches
    By 14erclimber in forum Queries
    Replies: 6
    Last Post: 06-09-2010, 09:29 AM

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