Results 1 to 14 of 14
  1. #1
    ltcarlisle is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    23

    Querying for matched first and last name combinations from two different tables


    I'm trying to make a query that finds first and last name combinations from two different tables, and displays the record associated with each of those combinations in one of the tables. For example, the two tables both have columns for FIRST and LAST names, and one of the tables has an ID associated with each person. I'd like to be able to get the ID for each person that comes up on both tables.

    In playing around with this, I've tried just joining FIRST names from the two tables and querying. Even though there are certainly matches in the FIRST name category, the query returned a blank list.

    Any thoughts? Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Did you try to join on both name fields? Does each table have first/last name combinations the other does not have? Is there a concern for spelling errors?

    What is purpose of this? Does each table have different data?
    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
    ltcarlisle is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    23
    Yes I also tried to join on both name fields and it again resulted in a blank list. Each table does have first/last name combinations that the other does not have, but each do have some in common -- those are the ones that I'm interested in. The purpose of this is, again, to find the first/last name combinations on the table with the unique ID that match first/last name combinations on another table. I want to use the unique ID associated with a matched first/last name combination and query that ID with other tables

    Also there is no concern for spelling errors, neither for punctuation as all of the names are in ALL CAPS

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    I don't understand. If it's the ID you want then just use the table with the ID. What is accomplished by joining to table that does not have ID?

    Access is by default not case sensitive so the ALL CAPS is likely irrelevant.
    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.

  5. #5
    ltcarlisle is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    23
    But I only want the ID of the record with the first/last name combination that matches the first/last name combination of the other table.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Then an INNER JOIN on both fields should do that. That should return only records with the name in both tables. No filter criteria required.
    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.

  7. #7
    ltcarlisle is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    23
    Great, could you tell me more about how INNER JOIN works?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    INNER JOIN requires related records in both tables.

    Query in design view, click on the line linking tables, set join type.
    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.

  9. #9
    ltcarlisle is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    23
    Thanks for your help!

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    See this for details on syntax and usage.

    Did you try Google "Inner Join"? You'd be surprised how much google/bing can find and quickly.

  11. #11
    ltcarlisle is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    23
    Apparently my join was an INNER JOIN by default -- still when I use the FIRST names as my destination field, I get blank lists

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    That doesn't make sense. Post query or provide db for analysis.
    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.

  13. #13
    ltcarlisle is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    23
    Nevermind -- the resulting query table is so big that it it took a long time to run. After some time, the results were displayed.

    The primary reason for which the query table was so large was because there were many BLANKS that matched. Any advice on how to ignore BLANKS in querying for matches?

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Maybe don't include any records where any of the 4 fields is Null? So the criteria would be Is Null under each field but on separate rows so the OR operator is invoked.
    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. Replies: 1
    Last Post: 07-23-2013, 01:39 AM
  2. Querying 2 or more tables
    By NewbieInCT in forum Queries
    Replies: 12
    Last Post: 05-11-2012, 09:49 AM
  3. Default values from matched ids in tables
    By JFo in forum Programming
    Replies: 41
    Last Post: 10-27-2011, 02:11 AM
  4. Last matched item in an unmatching query
    By kabaa01 in forum Queries
    Replies: 0
    Last Post: 05-19-2010, 03:46 PM
  5. Querying from 2 tables
    By egnaro in forum Queries
    Replies: 6
    Last Post: 01-28-2010, 06:30 PM

Tags for this Thread

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