By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,615 Members | 1,961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,615 IT Pros & Developers. It's quick & easy.

Query on 2 tables using two fields

P: 2
Hi,

I have spent a few days on this problem and it is driving me nuts. I have two tables called Parcels and Assessments. Both tables have two fields Printkey and SWIS. I have to join the fields based on the Printkey field plus the SWIS field being equal between the two tables. The SQL statment kind of works but does not grab all the records it is supposed to. It is a homework question but I just need to be pointed in the right direction. Am I even close?

Here is the SQL statement:

SELECT ASSESSMENT.PRKEY, ASSESSMENT.SWIS, ASSESSMENT.OWNER, ASSESSMENT.STREETNUM, ASSESSMENT.STREETNAME, ASSESSMENT.PROPTYPE, PARCELS.AREA
FROM ASSESSMENT INNER JOIN PARCELS ON (ASSESSMENT.SWIS = PARCELS.SWIS) AND (ASSESSMENT.PRKEY = PARCELS.PRINTKEY)
WHERE (([ASSESSMENT]![PRKEY]=[PARCELS]![PRINTKEY] And [ASSESSMENT]![SWIS]=[PARCELS]![SWIS]));
Oct 26 '06 #1
Share this Question
Share on Google+
4 Replies


NeoPa
Expert Mod 15k+
P: 31,442
That's pretty close to my mind - just lose the whole WHERE clause as it's tautologous (great word that - expresses again what has already been expressed).
The FROM clause with the INNER JOIN will only allow records where the two pairs of fields match from each of the two constituent tables.
Oct 26 '06 #2

NeoPa
Expert Mod 15k+
P: 31,442
Couldn't edit previous post as 5 min limit had expired.

Just wanted to add that the '!'s in the WHERE clause should have been '.'s.
Oct 26 '06 #3

P: 2
Thanks. I did catch the !. Not Sure how that happened so that is fixed.

Sue
Oct 27 '06 #4

MMcCarthy
Expert Mod 10K+
P: 14,534

tautologous (great word that - expresses again what has already been expressed).
Great word, I like it.

Should be part of the vocabulary of all programmers.
Oct 27 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.