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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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,223,275
Messages
6,171,127
Members
452,381
Latest member
Nova88

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