I have the following query which takes an absolute age to run in Access, but when run on MySQL is done in a flash. Access appears to lock up completely when I try to run the report generated from this query. Because the resultset is going to be used as a part of a nested subreport, I can't just run it s a passthrough query.
All of the referenced tables are standard tables, except for RepsForComps, which is a view on the MySQL Server. RepsForComps looks at a counties table, an employee table, and an override column in the Companies table to determine which employee a company is assigned to, given the county a company is in, and any override status.
Anyhow, my very slow query.
All of the referenced tables are standard tables, except for RepsForComps, which is a view on the MySQL Server. RepsForComps looks at a counties table, an employee table, and an override column in the Companies table to determine which employee a company is assigned to, given the county a company is in, and any override status.
Anyhow, my very slow query.
Code:
SELECT
r.name
, p.[First Name] & " " & p.[last name] AS perName
, c.Company
, c.Address_1
, c.Address_2
, c.Town
, c.County
, c.Postcode
FROM users AS u
RIGHT JOIN ((companies AS c
INNER JOIN RepsForComps AS r ON c.Comp_ID = r.Comp_ID)
INNER JOIN people AS p ON c.Comp_ID = p.Comp_ID) ON u.email = p.Email
WHERE (((u.time)>=[Forms]![FollowRep]![Range].[Form]![Start]
AND (u.time)<=[Forms]![FollowRep]![Range].[Form]![End]))
GROUP BY r.name, p.[First Name] & " " & p.[last name], c.Company, c.Address_1, c.Address_2, c.Town, c.County, c.Postcode
ORDER BY Count(u.email);