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

    Left Join Query Issue - MS Access

    I am trying to join two tables Table1 and Table2 using the query below. I want all the columns (and rows) from Table1 and Column 'DuplicateInIndex_BasedOnDate' from Table2.


    The problem is, all the values in column DuplicateInIndex_BasedOnDate are being set to 1 after the left join, instead of on the rows where is a match in both the tables.
    Can someone comment on where the problem lies?

    The query I am using right now:


    SELECT Table1.*, Table2.DuplicateInIndex_BasedOnDate
    FROM Table1LEFT JOIN Table2 ON (Table1.
    Name
    = Table2.
    Name
    ) AND (Table1.
    Date-4
    = Table2
    Date-4
    ) AND (Table1.
    Date-3
    = Table2
    Date-3
    ) AND (Table1.
    Date-2
    = Table2.
    Date-2
    ) AND (Table1.
    Date-1
    = Table2.
    Date-1
    ) AND (Table1.
    CustomerID
    = Table2.
    CustomerID
    ) AND (Table1.
    Site
    = Table2.
    Site
    );







    Table2:
    Site CustomerID Date-1 Date-2 Date-3 Date-4 Name DuplicateInIndex_BasedOnDate
    00001 201 3/30/2011 4/6/2011 4/3/2011 4/6/2011 Hospital-1 1









    Table1:
    Site CustomerID Date-1 Date-2 Date-3 Date-4 Name
    00001 101 5/21/2011 5/28/2011 5/21/2011 5/28/2011 Hospital-5
    00001 101 12/12/2011 12/17/2011 12/12/2011 12/17/2011 Hospital-4
    00001 101 3/28/2012 4/11/2012 3/28/2012 4/11/2012 Hospital-2
    00001 201 3/30/2011 4/6/2011 4/3/2011 4/6/2011 Hospital-1
    00001 202 9/5/2011 9/12/2011 9/5/2011 9/12/2011 Hospital-3
    00001 202 9/16/2011 9/20/2011 9/16/2011 9/20/2011 Hospital-3
    00001 202 9/29/2011 10/4/2011 9/29/2011 10/4/2011 Hospital-3


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Did you get this solved?

    Could you post the actual SQL statement instead?


    Advise not to use spaces and special characters/punctuation (underscore is exception) in names. If used, enclose name in []. Have you had problem with other queries using those Date-x fields?
    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. Query join issue?
    By ajkosby in forum Queries
    Replies: 4
    Last Post: 07-16-2013, 05:03 AM
  2. Inner Join works but not Left Join
    By kwooten in forum Queries
    Replies: 1
    Last Post: 12-11-2012, 05:09 PM
  3. Left Join not
    By j_a_monk in forum Queries
    Replies: 5
    Last Post: 08-07-2011, 09:47 AM
  4. inner, left or right join ?
    By toqilula in forum Access
    Replies: 0
    Last Post: 04-11-2011, 12:20 AM
  5. Replies: 3
    Last Post: 02-02-2011, 01:00 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