INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Select from 3 tables does not work

Select from 3 tables does not work

(OP)
I want to select from these 3 tables :

table Members
table Activities (= matches, location, time etc. )
table CombCt (= who plays when where which matches => with reference fields to/from Members + Activities

=> The following 2 test queries each from 2 tables combinations work:

SELECT CombCt.*, Activities.place, Activities.ref
FROM (Activities inner JOIN CombCt ON Activities.actdat=Combct.actDat)
ORDER BY Combct.actDat ASC

SELECT CombCt.*, Members.membernum, Members.name
FROM (Members left JOIN CombCt ON Members.membernum=CombCt.membernum)
WHERE Members.membernum>=1
ORDER BY Members.name, Combct.actDat ASC


=> But this query from the 3 tables does not work:

SELECT CombCt.*, Activities.place, Activities.ref, Members.membernum, Members.name
FROM Activities inner JOIN CombCt ON Activities.actdat=CombCt.actDat
left JOIN Members ON Members.membernum=CombCt.membernum)
WHERE Members.membernum>=1
ORDER BY Members.name, Combct.actDat ASC

Thanks for help tips
Leifoet

RE: Select from 3 tables does not work

What do you mean by "does not work"?
Are these the primary keys:
Activities.actDat
Members.membernum
CombCt.?

Duane
Vevey, Switzerland
Hook'D on Access
MS Access MVP 2001-2016

RE: Select from 3 tables does not work

(OP)
"does not work" =>
Database Results Error
Description: Syntax error in FROM clause.
Number: -2147217900 (0x80040E14)
Source: Microsoft JET Database Engine

The primary keys:
Activities.actDat
Members.membernum
CombCt =>
CombCt.actDat (inner join)
CombCt.membernum (left join)

RE: Select from 3 tables does not work

Your SQL seems to be missing a "("

CODE --> SQL

SELECT CombCt.*, Activities.place, Activities.ref, Members.membernum, Members.name 
FROM Activities inner JOIN CombCt ON Activities.actdat=CombCt.actDat 
left JOIN Members ON Members.membernum=CombCt.membernum) 
WHERE Members.membernum>=1 
ORDER BY Members.name, Combct.actDat ASC 

I'm not sure where the ( should go so I would start over in the design view.

Duane
Vevey, Switzerland
Hook'D on Access
MS Access MVP 2001-2016

RE: Select from 3 tables does not work

(OP)
I have re-tested the location of the brackets => the query is working now

SELECT CombCt.*, Activities.place, Activities.ref, Members.membernum, Members.name
FROM Activities (inner JOIN CombCt ON Activities.actdat=CombCt.actDat)
left JOIN Members ON Members.membernum=CombCt.membernum
WHERE Members.membernum>=1
ORDER BY Members.name, Combct.actDat ASC

Thanks dhookom for your solving tip.

RE: Select from 3 tables does not work

(OP)
I copied the wrong test query.
This is working!
Sorry.

SELECT CombCt.*, Activities.place, Activities.ref, Members.membernum, Members.name
FROM (Activities inner JOIN CombCt ON Activities.actdat=CombCt.actDat)
left JOIN Members ON Members.membernum=CombCt.membernum
WHERE Members.membernum>=1
ORDER BY Members.name, Combct.actDat ASC

RE: Select from 3 tables does not work

leifoet,
Don't you think Duane deserves a star for the help provided?
Click on Great Post link in the most helpful post.

Have fun.

---- Andy

There is a great need for a sarcasm font.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close