One query works; the other doesn't.

Mark McCumber 431 Reputation points
2022-08-27T17:53:31.733+00:00

Can someone tell me the difference in these two queries?

This one returns data.
SELECT * FROM tblFEC_Raw_Data
INNER JOIN tblStates
ON tblFEC_Raw_Data.CAND_OFFICE_ST = dbo.tblStates.StateAbbrv;

This one doesn’t.
SELECT * FROM tblFEC_Raw_Data
INNER JOIN tblCand_Office
ON tblFEC_Raw_Data.CAND_OFFICE = dbo.tblCand_Office.Office;

The table tblCand_Office contains the following entries.
1 House
2 President
3 Senate
What is happening?

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,544 questions
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 100.7K Reputation points MVP
    2022-08-27T20:18:39.357+00:00

    I guess then that there is no data in tblFEC_Raw_Data.CandOffice that has any of these three values.

    For a deeper analysis, I would CREATE TABLE + INSERT that demonstrates the problem. With the information you have provided now, guess is all I can offer.


0 additional answers

Sort by: Most helpful