Why are these 2 FROM statements not the same?

G

Guest

Below are two From statements and i don't understand Access's use of
parenthesis. I typically don't even use them when making my statements but
Access requires them and i dont' understand them.

Thanks!

SELECT Employee.EmployeeID, Sum(SickTime.SickTime) AS SickTime,
Sum(VacationTime.VacationTime) AS VacationTime,
Sum(PersonalTime.PersonalTime) AS PersonalTime

FROM ((((Department INNER JOIN ON Department.DepartmentID =
Employee.DepartmentID) Center INNER JOIN Employee ON Center.CenterID =
Employee.CenterID) LEFT
JOIN PersonalTime ON Employee.EmployeeID = PersonalTime.EmployeeID) LEFT
JOIN SickTime ON Employee.EmployeeID = SickTime.EmployeeID) LEFT JOIN
VacationTime ON Employee.EmployeeID = VacationTime.EmployeeID

WHERE (((Department.DepartmentID)=1))
GROUP BY Employee.EmployeeID;

------------
SELECT Employee.EmployeeID, Sum(SickTime.SickTime) AS SickTime,
Sum(VacationTime.VacationTime) AS VacationTime,
Sum(PersonalTime.PersonalTime) AS personaltime

FROM (((Department INNER JOIN (Center INNER JOIN Employee ON Center.CenterID
= Employee.CenterID) ON Department.DepartmentID = Employee.DepartmentID) LEFT
JOIN PersonalTime ON Employee.EmployeeID = PersonalTime.EmployeeID) LEFT JOIN
SickTime ON Employee.EmployeeID = SickTime.EmployeeID) LEFT JOIN VacationTime
ON Employee.EmployeeID = VacationTime.EmployeeID

WHERE (((Department.DepartmentID)=1))
GROUP BY Employee.EmployeeID;
 
M

Marshall Barton

jacob said:
Below are two From statements and i don't understand Access's use of
parenthesis. I typically don't even use them when making my statements but
Access requires them and i dont' understand them.

SELECT Employee.EmployeeID, Sum(SickTime.SickTime) AS SickTime,
Sum(VacationTime.VacationTime) AS VacationTime,
Sum(PersonalTime.PersonalTime) AS PersonalTime

FROM ((((Department INNER JOIN ON Department.DepartmentID =
Employee.DepartmentID) Center INNER JOIN Employee ON Center.CenterID =
Employee.CenterID) LEFT
JOIN PersonalTime ON Employee.EmployeeID = PersonalTime.EmployeeID) LEFT
JOIN SickTime ON Employee.EmployeeID = SickTime.EmployeeID) LEFT JOIN
VacationTime ON Employee.EmployeeID = VacationTime.EmployeeID

WHERE (((Department.DepartmentID)=1))
GROUP BY Employee.EmployeeID;

------------
SELECT Employee.EmployeeID, Sum(SickTime.SickTime) AS SickTime,
Sum(VacationTime.VacationTime) AS VacationTime,
Sum(PersonalTime.PersonalTime) AS personaltime

FROM (((Department INNER JOIN (Center INNER JOIN Employee ON Center.CenterID
= Employee.CenterID) ON Department.DepartmentID = Employee.DepartmentID) LEFT
JOIN PersonalTime ON Employee.EmployeeID = PersonalTime.EmployeeID) LEFT JOIN
SickTime ON Employee.EmployeeID = SickTime.EmployeeID) LEFT JOIN VacationTime
ON Employee.EmployeeID = VacationTime.EmployeeID

WHERE (((Department.DepartmentID)=1))
GROUP BY Employee.EmployeeID;


The first one is missing a INNER JOIN before the Center
table.

Note that the parenthesis are just used to specify the order
that the joins are done. This is much like using
parenthesis to specify the order of calculations on an
arithmetic expression.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top