Discussion Locked

Access Query

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have been struggling with the following in access:
I have two tables in the query. The tables are linked by an id number. I want to query it so that I get all the names of community memebrs who are Republican, Demicratic, etc. The second table give me voting history. I want to pull from the second table all the REpublicans who voted in ech of the following years: 2004,2003 and 2002. My query gives me the names of the ones who ahve voted in each year rather than in all three years. How do I fix it? Thanks.

1 reply

by tony hopkinson

If you sort out the table & field names.

Select Members.*
From Members, VotingHistory v2002, VotingHistory v2003, VotingHistory v2004
Where Member.Party = 'Republican'
And Member.ID = v2002.ID
And Member.ID = v2003.ID
And Member.ID = v2004.ID
And V2002.Year = 2002
And V2003.Year = 2003
And V2004.Year = 2004

Uses aliases so can join to the voting history table more than once.

The other way would be a having clause, can't think of the exact syntax off the top of my head
But if you tested for years in the range you wanted and Having Count >= 3, sopmething like that anyway.

This discussion is closed to new replies.