Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select from 3 tables does not work

Status
Not open for further replies.

leifoet

Technical User
Jan 31, 2016
203
BE
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
 
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
 
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)

 
Your SQL seems to be missing a "("

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[highlight #FCE94F])[/highlight] 
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
 
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.
 
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
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top