Reply
two tables in Access. Help please.
Old 04-11-2008, 12:17 PM two tables in Access. Help please.
leadingzero's Avatar
tired of the day job

Posts: 88
I am trying to run the following query where A and B are separate tables in the database:

Code:
SELECT area 
FROM A
WHERE B.area = A.area;
However, when I try to run it prompts for B.area as if it was a user submitted value. Any idea how to get this working?
leadingzero is offline
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Old 04-11-2008, 02:22 PM Re: two tables in Access. Help please.
Learning Newbie's Avatar
Moderator

Latest Blog Post:
More of John McCain’s Lies
Posts: 4,155
Name: John Alexander
You need to include B in your from clause. Then you need to either create a join clause (FROM A JOIN B ON A.x = B.x) or put the condition in your WHERE clause that will tell the database engine how to combine the tables. Which it looks like you already have.
__________________
HungarianNotation is the last resort of scoundrels. Why not the first resort? That's where it counts!
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 04-11-2008, 04:01 PM Re: two tables in Access. Help please.
leadingzero's Avatar
tired of the day job

Posts: 88
Thanks Newbie. Talkupation added.
I had to use the JOIN to get it working. I'll know next time.
leadingzero is offline
Reply With Quote
View Public Profile
 
Old 04-11-2008, 04:29 PM Re: two tables in Access. Help please.
Learning Newbie's Avatar
Moderator

Latest Blog Post:
More of John McCain’s Lies
Posts: 4,155
Name: John Alexander
I've never looked into the performance implications of each, but with a smart query optimizer I think they'd be the same. Thanks for the TP (!), and now that you've figured it out, I'll spill the answer for others. If that sounds mean, since you went and figured it out and implemented it yourself, like you said, you'll remember in future, so it's actually valuable to wait with the answer.

SELECT area
FROM A INNER JOIN B ON B.area = A.area


Or

SELECT area
FROM A, B
WHERE B.area = A.area;The second one is the old ANSI SQL way of doing it. I think most people prefer the JOIN syntax. If the query processor isn't in top shape, I think JOIN might be a little faster, but they're probably the same.
__________________
HungarianNotation is the last resort of scoundrels. Why not the first resort? That's where it counts!
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 04-15-2008, 11:26 PM Re: two tables in Access. Help please.
igniz's Avatar
Experienced Talker

Posts: 33
Name: frost
Location: philippines
SELECT area
FROM A, B
WHERE B.area = A.area;

adding B with do... because B.Area only reflects A.Area. i hope it works
igniz is offline
Reply With Quote
View Public Profile Visit igniz's homepage!
 
Sponsored Links (We share ad revenue):
 
Reply     « Reply to two tables in Access. Help please.
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML


Page generated in 0.38088 seconds with 15 queries