Results 1 to 14 of 14
  1. #1
    MrJukas is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2015
    Posts
    13

    Post Left Join

    Hello,

    I have a question with Access. I hope some of you would find the time to assist me.

    Problem:
    Table1: Item list
    Table2: Item list , Location , Quantity




    With a left join Table1->Table2 on the Item list.


    What I am looking for:
    I'd like to have all items from Table1 and for those that are in Table2, I want to see the quantity in the location "UK".

    Is it clear enough?

    When I try to put the criteria "UK" for the field Location, it returns only the items from Table2 that have location as "UK".

    I assume that I cannot use left join, can I?

    thank you guys.
    Jukas

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    A few sample records from each table would be helpful.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Don't understand. If you filter by "UK" then only records with UK will display. If you want to show all Items but Quantity only when Location is UK, use an expression in query that returns Null if location is not UK and don't filter records.

    IIf(Location="UK", Quantity, Null)

    But why show a location if you don't want to show Quantity?
    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.

  4. #4
    MrJukas is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2015
    Posts
    13
    Table1
    Item
    A
    B
    C


    Table2
    Item Location quantity
    A USA 1
    A UK 2
    B USA 3
    B UK 4


    What I d like to see
    Item Location Quantity
    A UK 2
    B UK 4
    C


    Makes sense?

  5. #5
    MrJukas is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2015
    Posts
    13
    Quote Originally Posted by June7 View Post
    Don't understand. If you filter by "UK" then only records with UK will display. If you want to show all Items but Quantity only when Location is UK, use an expression in query that returns Null if location is not UK and don't filter records.

    IIf(Location="UK", Quantity, Null)

    But why show a location if you don't want to show Quantity?

    Your formula makes perfectly sense, and I was actually thinking about using something like that. But I was wondering if it would have been possible something without Iif()

    thanks

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    While in design view of your query object, double click the line that connects the two tables (join). That should bring up a properties dialog box. Choose the option, "Include all records from Table1 and only those ..."

    With this you should be able to type Like 'UK' in the criteria. Or you can just type 'UK' for an exact match. You can uncheck the box to view your Location column. And be sure to include the Quantity column in your query by dragging it from the table onto the grid.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Maybe with a series of queries.

    Query1
    to filter records to UK

    Query2
    RIGHT join query 1 to list of locations
    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.

  8. #8
    MrJukas is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2015
    Posts
    13
    Unfortunately, with the left join it gives only the UK values.

    I was thinking to use <>USA criteria, but it wasn't 100% successful

  9. #9
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Did you try using single quotes around USA? <> 'USA'

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I said RIGHT join.

    If you want to provide db for analysis and testing, follow instructions at bottom of my post.
    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.

  11. #11
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by June7 View Post
    I said RIGHT join...
    Thanks for the clarification.

  12. #12
    DrGUI is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Aug 2015
    Location
    Parts Unknown
    Posts
    23
    Use a LEFT join but for the Location criteria, use: 'UK' or Is NULL

  13. #13
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by DrGUI View Post
    Use a LEFT join but for the Location criteria, use: 'UK' or Is NULL
    That makes sense because the <> will not retrieve Null.

  14. #14
    MrJukas is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2015
    Posts
    13
    Quick update.
    I tried the iff (), it didn't work because it considers USA values a 0 quantity, so I have a table duplicates with 0s.
    Yet, I might try to tell him to sum them, rather than group it by. In theory it should work.

    I am not sure the left join with UK or is null would work. I haven't really the time to try it.

    I ll get back to you all soon, most likely over the weekend.
    Thanks for the help

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

Similar Threads

  1. Inner Join works but not Left Join
    By kwooten in forum Queries
    Replies: 1
    Last Post: 12-11-2012, 05:09 PM
  2. Left Join not
    By j_a_monk in forum Queries
    Replies: 5
    Last Post: 08-07-2011, 09:47 AM
  3. inner, left or right join ?
    By toqilula in forum Access
    Replies: 0
    Last Post: 04-11-2011, 12:20 AM
  4. Replies: 3
    Last Post: 02-02-2011, 01:00 PM
  5. Problem with Left Join & VB6
    By msrdjan1 in forum Queries
    Replies: 0
    Last Post: 03-30-2010, 01:48 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