Results 1 to 6 of 6
  1. #1
    jhuvba is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    3

    Simple query returns no results


    I have a simple query to join information from two tables based on a matching primary key:

    Code:
    SELECT Visits.Date, Results.IDFROM Visits INNER JOIN Results ON Visits.Id=Results.ID;
    There are about 250,000 records in the visits table, and 8000 in the results table. I have double checked in Excel and all IDs from Results are found in Visits. However, this query returns no results. A Left Join will only return Visits.Date with no Results.ID, a Right Join will only return Results.ID with no Visit.Date. Any idea what is going on? I'm able to run join queries from Visits with other tables in my DB using the same ID key or other fields. Any query I run that includes the results table returns no records, however.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    As far as the database engine is concerned, there are no records where those fields match. Can you attach the db here, or at least a picture of the two tables showing those fields?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jhuvba is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    3
    Unfortunately given the data in the workbook, I'm not sure I can upload a sample or photo without changing the keys to anonymize it. If you have any suggestions on how to upload it or how to fix this I'd appreciate it!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Are the data types the same? Can you copy/paste values from those fields that should match? Could there be spaces in one and not the other?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    jhuvba is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    3
    Figured it out. My input mask was hiding the problem. For some reason the Results.ID field was stored without a decimal point, but had one added from the input mask, while the Visits.ID had a decimal point in the actual string.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Glad you got it sorted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Left Join Query returns invalid results
    By darike in forum Queries
    Replies: 13
    Last Post: 09-07-2016, 06:51 AM
  2. Simple form to query results from a test DB
    By Pharmboy in forum Access
    Replies: 3
    Last Post: 02-23-2013, 11:06 AM
  3. Replies: 4
    Last Post: 02-22-2012, 12:43 PM
  4. Query returns ro results
    By MichealShinn in forum Queries
    Replies: 5
    Last Post: 02-21-2012, 01:24 PM
  5. Replies: 13
    Last Post: 01-13-2011, 10:15 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