query returning 0 records

dogdays

Active Member
Joined
Apr 28, 2008
Messages
434
Office Version
  1. 2007
I have two queries, one returns 0 records, the second returns 1 record.
Both queries were generated using query design.
I am missing something and it is driving me nuts.
The WHERE clause does contain a valid tvoterID.
No error messages were generated.

Code:
' this query returns 0 records

SELECT tblVoters.tVoterId, 
       tblVoters.tVoterType, 
       tblVoters.tStatusCode, 
       tblVoters.tLastname, 
       tblVoters.tFirstName, 
       tblVoters.tMiddleName, 
       tblVoters.tPrefix, 
       tblVoters.tSuffix, 
       tblVoters.nStreetNumber, 
       tblVoters.tStreetname, 
       tblVoters.tStreetName2, 
       tblVoters.tZipcode, 
       tblVoters.tZip4code, 
       tblVoters.tCity, 
       tblVoters.tUnit, 
       tblVoters.tSuffixA, 
       tblVoters.tSuffixB, 
       tblVoters.tState, 
       tblVoters.tPartyCode, 
       tblVoters.tSex, 
       tblVoters.dtBirth, 
       tblVoters.tCongressionalDistrict, 
       tblVoters.tStateSenateDistrict, 
       tblVoters.tStateRepDistrict, 
       tblVoters.nAge, 
       tblVoters.nSupportCode, 
       tblVoters.nIssueCode, 
       tblComments.tHomePhone, 
       tblComments.tMobilePhone, 
       tblComments.tEmail, 
       tblComments.tComments
FROM (tblVoters INNER JOIN tblComments ON tblVoters.tVoterId = tblComments.tVoterID)
     INNER JOIN tblMailingAddress ON tblVoters.tVoterId = tblMailingAddress.tVoterID
WHERE tblVoters.tVoterID = '23000550548';


' this query returns 1 record

SELECT tblVoters.nHouseholdNumber
FROM tblVoters
WHERE tblVoters.tVoterID = '23000550548';
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Does the tVoterID you are using in the criteria appear in all the tables in your join?

Are you sure you are using the right type of join perhaps you should be using LEFT JOIN?
 
Upvote 0
Agreed - because of the inner join, you would get zero results if the particular VoterID did not exist in either of the tblComments or tblMailingAddress tables.
 
Upvote 0

Forum statistics

Threads
1,221,704
Messages
6,161,390
Members
451,701
Latest member
ckrings

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top