Results 1 to 3 of 3
  1. #1
    Anetal is offline Novice
    Windows XP Access 2016
    Join Date
    Jan 2021
    Posts
    7

    Left join

    Hi. I am having trouble joining tables. I want to add data to one table from the other after the key: year and number. I do not have some years in the second table, and yet when connecting, I see values. Why is this happening?


    Table 1

    year number
    2020
    2021
    2019 1
    2019 2


    year Value number
    2019 2 1
    2019 10 2
    Year number Wyr1
    2019 1 TRUE
    2020
    FALSE
    2021
    FALSE
    2019 2 FALSE
    Hi. 44llI a
    year Value number
    2019 2 1
    2019 10 2
    m having trouble joining tables. I want to add data to one table from the other after the key: year and number. I do not have some years in the second table, and yet when connecting, I see values. Why is this happening?
    Attached Files Attached Files

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,004
    It's not very obvious what you really want but I'll stab a guess that this might be what your after;

    Code:
    SELECT [table 1].year, [table 1].number, [table 2].Value
    FROM [table 1] LEFT JOIN [table 2] ON ([table 1].number = [table 2].number) AND ([table 1].year = [table 2].year);
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I realize that your example is probably something you threw together, but "Year", "Value" and "Number" are reserved words and shouldn't be used for object names.
    Just sayn' .

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

Similar Threads

  1. Replies: 7
    Last Post: 07-10-2020, 11:44 AM
  2. INNER JOIN vs LEFT OUTER JOIN
    By shylock in forum Access
    Replies: 3
    Last Post: 10-16-2018, 09:38 AM
  3. Replies: 3
    Last Post: 09-20-2017, 09:50 AM
  4. Inner Join works but not Left Join
    By kwooten in forum Queries
    Replies: 1
    Last Post: 12-11-2012, 05:09 PM
  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