Access-SQL: Inner Join with multiple tables
Solution 1:
If you are writing a query against an Access database backend, you need to use the following join syntax:
select
t1.c1
, t2.c2
, t3.c3
, t4.c4
from ((t1
inner join t2 on t1.something = t2.something)
inner join t3 on t2.something = t3.something)
inner join t4 on t3.something = t4.something
The table and column names aren't important here, but the placement of the parentheses is. Basically, you need to have n - 2 left parentheses after the from
clause and one right parenthesis before the start of each new join
clause except for the first, where n is the number of tables being joined together.
The reason is that Access's join syntax supports joining only two tables at a time, so if you need to join more than two you need to enclose the extra ones in parentheses.
Solution 2:
SELECT tblOjt.id, tblStudent.firstname, tblStudent.middlename,
tblStudent.lastname, tblStudent.course, tblCompany.companyname,
tblAddressee.addressee
FROM (((tblOjt
INNER JOIN tblStudent ON tblOjt.studentid = tblStudent.id)
INNER JOIN tblCourse ON tblOjt.courseid = tblCourse.id)
INNER JOIN tblCompany ON tblOjt.companyid = tblCompany.id)
INNER JOIN tblAddressee ON tblOjt.addresseeid = tbladdressee.id
found it!thanks to Yawar's approach...