Results 1 to 4 of 4
  1. #1
    shabar is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    66

    Table field comparison

    Hi All
    I ran following query for field comparison in Tab1 and Tab2. Needs to check what are the Col1 values missing in
    Tab2


    SELECT Tab1.*


    FROM Tab1 LEFT JOIN Tab2 IM ON Tab1.Col1 = Tab2.Col2
    WHERE Tab2.Col2 Is Null;

    Here count is 16177

    When I run same query with NOT NULL as follows

    SELECT Tab1.*
    FROM Tab1 LEFT JOIN Tab2 IM ON Tab1.Col1 = Tab2.Col2
    WHERE Tab2.Col2 Is not Null;

    I got count as 3190200

    But total of above two should tally to Tab1 total row count (i.e. 17683 as follows)

    But When I check Tables row count seperately its as follws

    Tab1 17683
    Tab2 1642488


    What could be the issue

    Cheers

    Shabar

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What is the 'IM' in the sql statement? Never seen that.

    Could be duplicate values in one or both of the tables to cause the increased record count.

    Try:

    SELECT Tab1.Col1
    FROM Tab1 LEFT JOIN Tab2 ON Tab1.Col1 = Tab2.Col2
    WHERE Tab2.Col2 Is Null;

    Or

    SELECT Tab1.Col1
    FROM Tab2 RIGHT JOIN Tab1 ON Tab2.Col2 = Tab1.Col1
    WHERE Tab2.Col2 Is Null;

    Both worked for me.
    Last edited by June7; 01-31-2013 at 02:10 PM.
    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
    shabar is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    66
    Thax June7

    'IM' is a typo. Sorry about that

    Since I do get duplicate in both tables this row count may appear. Anyway do you have idea how its arrived



    Cheers

    Shabar

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The duplicate records must each join to the corresponding record(s) in other table. This increases record count to greater than in each table alone. If the purpose is just to determine if Tab1.Col1 data is in Tab2.Col2 then the count might be irrelevant. Depends what you want to do.
    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
    By raytackettsells in forum Queries
    Replies: 2
    Last Post: 08-06-2012, 05:30 PM
  3. Values comparison
    By Rekha V in forum Access
    Replies: 10
    Last Post: 03-24-2012, 10:29 PM
  4. Replies: 7
    Last Post: 01-28-2011, 11:15 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