B
bhipwell via AccessMonster.com
Hello,
This is for a Employee Benefit Database.
I have a query referencing 17 tables. 2 of the tables just provide general
information, employer data and class data. The other 15 tables contain class
information for each type of available employee benefit (health, dental, life,
etc.).
The 15 tables contain a field (HealthInfoID, DentalInfoID, etc.) which
references other tables with specific plan information. Since each employee
benefit can have multiple plan options, those indexes create every
combination resulting in 49,152 rows.
Each of the 15 tables has a field called ...Offered. All I need to know is
whether a benefit for a particular class (equal to a class on a specified
form) is offered ("Yes").
Any thoughts? I can't seem to find any way not to have the query compute
every combination.
Thanks in advance! Here is the SQL:
SELECT tblEmployer.CoCompanyID, tblClass.CoClassName, tblEmployer.CoName,
tblEmployer.CoLogo, tblEmployer.CoStreet, tblEmployer.CoCity, tblEmployer.
CoState, tblEmployer.CoZip, tblEmployer.CoPhone, tblClassHEAL.HEALOffered,
tblClassDEN1.DEN1Offered, tblClassVISI.VISIOffered, tblClassLIFE.LIFEOffered,
tblClassDLIF.DLIFOffered, tblClassLIFX.LxOffered, tblClassLIFS.LsOffered,
tblClassLIFC.LcOffered, tblClassSTD.STDOffered, tblClassLTD.LTDOffered,
tblClassVSTD.VSTDOffered, tblClassVLTD.VLTDOffered, tblClassHSA.
HsClassOffered, tblEmployer.CoPOPOffered, tblClassFSA.FSAClassOffered,
tblClassSUPP.SUPPClassOffered
FROM (((((((((((((tblClass INNER JOIN ((tblEmployer INNER JOIN tblClassHEAL
ON tblEmployer.CoCompanyID = tblClassHEAL.CoCompanyID) INNER JOIN
tblClassDEN1 ON tblEmployer.CoCompanyID = tblClassDEN1.CoCompanyID) ON
(tblEmployer.CoCompanyID = tblClass.CoCompanyID) AND (tblClass.ClClassID =
tblClassDEN1.ClClassID) AND (tblClass.ClClassID = tblClassHEAL.ClClassID))
INNER JOIN tblClassVISI ON (tblEmployer.CoCompanyID = tblClassVISI.
CoCompanyID) AND (tblClass.ClClassID = tblClassVISI.ClClassID)) INNER JOIN
tblClassDLIF ON (tblEmployer.CoCompanyID = tblClassDLIF.CoCompanyID) AND
(tblClass.ClClassID = tblClassDLIF.ClClassID)) INNER JOIN tblClassLIFE ON
(tblEmployer.CoCompanyID = tblClassLIFE.CoCompanyID) AND (tblClass.ClClassID
= tblClassLIFE.ClClassID)) INNER JOIN tblClassLIFX ON (tblEmployer.
CoCompanyID = tblClassLIFX.CoCompanyID) AND (tblClass.ClClassID =
tblClassLIFX.ClClassID)) INNER JOIN tblClassLIFS ON (tblClass.ClClassID =
tblClassLIFS.ClClassID) AND (tblEmployer.CoCompanyID = tblClassLIFS.
CoCompanyID)) INNER JOIN tblClassLIFC ON (tblEmployer.CoCompanyID =
tblClassLIFC.CoCompanyID) AND (tblClass.ClClassID = tblClassLIFC.ClClassID))
INNER JOIN tblClassSTD ON (tblEmployer.CoCompanyID = tblClassSTD.CoCompanyID)
AND (tblClass.ClClassID = tblClassSTD.ClClassID)) INNER JOIN tblClassLTD ON
(tblEmployer.CoCompanyID = tblClassLTD.CoCompanyID) AND (tblClass.ClClassID =
tblClassLTD.ClClassID)) INNER JOIN tblClassVSTD ON (tblEmployer.CoCompanyID =
tblClassVSTD.CoCompanyID) AND (tblClass.ClClassID = tblClassVSTD.ClClassID))
INNER JOIN tblClassVLTD ON (tblEmployer.CoCompanyID = tblClassVLTD.
CoCompanyID) AND (tblClass.ClClassID = tblClassVLTD.ClClassID)) INNER JOIN
tblClassHSA ON (tblEmployer.CoCompanyID = tblClassHSA.CoCompanyID) AND
(tblClass.ClClassID = tblClassHSA.ClClassID)) INNER JOIN tblClassFSA ON
(tblEmployer.CoCompanyID = tblClassFSA.CoCompanyID) AND (tblClass.ClClassID =
tblClassFSA.ClClassID)) INNER JOIN tblClassSUPP ON (tblEmployer.CoCompanyID =
tblClassSUPP.CoCompanyID) AND (tblClass.ClClassID = tblClassSUPP.ClClassID)
WHERE (((tblEmployer.CoCompanyID)=[Forms]![FrmEmployerMain]![CoCompanyID])
AND ((tblClass.CoClassName)=[Forms]![FrmEnrollmentForms]![ClassForReports]));
This is for a Employee Benefit Database.
I have a query referencing 17 tables. 2 of the tables just provide general
information, employer data and class data. The other 15 tables contain class
information for each type of available employee benefit (health, dental, life,
etc.).
The 15 tables contain a field (HealthInfoID, DentalInfoID, etc.) which
references other tables with specific plan information. Since each employee
benefit can have multiple plan options, those indexes create every
combination resulting in 49,152 rows.
Each of the 15 tables has a field called ...Offered. All I need to know is
whether a benefit for a particular class (equal to a class on a specified
form) is offered ("Yes").
Any thoughts? I can't seem to find any way not to have the query compute
every combination.
Design issue?
Code to run faster?
What about "chaining" queries?
Thanks in advance! Here is the SQL:
SELECT tblEmployer.CoCompanyID, tblClass.CoClassName, tblEmployer.CoName,
tblEmployer.CoLogo, tblEmployer.CoStreet, tblEmployer.CoCity, tblEmployer.
CoState, tblEmployer.CoZip, tblEmployer.CoPhone, tblClassHEAL.HEALOffered,
tblClassDEN1.DEN1Offered, tblClassVISI.VISIOffered, tblClassLIFE.LIFEOffered,
tblClassDLIF.DLIFOffered, tblClassLIFX.LxOffered, tblClassLIFS.LsOffered,
tblClassLIFC.LcOffered, tblClassSTD.STDOffered, tblClassLTD.LTDOffered,
tblClassVSTD.VSTDOffered, tblClassVLTD.VLTDOffered, tblClassHSA.
HsClassOffered, tblEmployer.CoPOPOffered, tblClassFSA.FSAClassOffered,
tblClassSUPP.SUPPClassOffered
FROM (((((((((((((tblClass INNER JOIN ((tblEmployer INNER JOIN tblClassHEAL
ON tblEmployer.CoCompanyID = tblClassHEAL.CoCompanyID) INNER JOIN
tblClassDEN1 ON tblEmployer.CoCompanyID = tblClassDEN1.CoCompanyID) ON
(tblEmployer.CoCompanyID = tblClass.CoCompanyID) AND (tblClass.ClClassID =
tblClassDEN1.ClClassID) AND (tblClass.ClClassID = tblClassHEAL.ClClassID))
INNER JOIN tblClassVISI ON (tblEmployer.CoCompanyID = tblClassVISI.
CoCompanyID) AND (tblClass.ClClassID = tblClassVISI.ClClassID)) INNER JOIN
tblClassDLIF ON (tblEmployer.CoCompanyID = tblClassDLIF.CoCompanyID) AND
(tblClass.ClClassID = tblClassDLIF.ClClassID)) INNER JOIN tblClassLIFE ON
(tblEmployer.CoCompanyID = tblClassLIFE.CoCompanyID) AND (tblClass.ClClassID
= tblClassLIFE.ClClassID)) INNER JOIN tblClassLIFX ON (tblEmployer.
CoCompanyID = tblClassLIFX.CoCompanyID) AND (tblClass.ClClassID =
tblClassLIFX.ClClassID)) INNER JOIN tblClassLIFS ON (tblClass.ClClassID =
tblClassLIFS.ClClassID) AND (tblEmployer.CoCompanyID = tblClassLIFS.
CoCompanyID)) INNER JOIN tblClassLIFC ON (tblEmployer.CoCompanyID =
tblClassLIFC.CoCompanyID) AND (tblClass.ClClassID = tblClassLIFC.ClClassID))
INNER JOIN tblClassSTD ON (tblEmployer.CoCompanyID = tblClassSTD.CoCompanyID)
AND (tblClass.ClClassID = tblClassSTD.ClClassID)) INNER JOIN tblClassLTD ON
(tblEmployer.CoCompanyID = tblClassLTD.CoCompanyID) AND (tblClass.ClClassID =
tblClassLTD.ClClassID)) INNER JOIN tblClassVSTD ON (tblEmployer.CoCompanyID =
tblClassVSTD.CoCompanyID) AND (tblClass.ClClassID = tblClassVSTD.ClClassID))
INNER JOIN tblClassVLTD ON (tblEmployer.CoCompanyID = tblClassVLTD.
CoCompanyID) AND (tblClass.ClClassID = tblClassVLTD.ClClassID)) INNER JOIN
tblClassHSA ON (tblEmployer.CoCompanyID = tblClassHSA.CoCompanyID) AND
(tblClass.ClClassID = tblClassHSA.ClClassID)) INNER JOIN tblClassFSA ON
(tblEmployer.CoCompanyID = tblClassFSA.CoCompanyID) AND (tblClass.ClClassID =
tblClassFSA.ClClassID)) INNER JOIN tblClassSUPP ON (tblEmployer.CoCompanyID =
tblClassSUPP.CoCompanyID) AND (tblClass.ClClassID = tblClassSUPP.ClClassID)
WHERE (((tblEmployer.CoCompanyID)=[Forms]![FrmEmployerMain]![CoCompanyID])
AND ((tblClass.CoClassName)=[Forms]![FrmEnrollmentForms]![ClassForReports]));