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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which query design is better?

Status
Not open for further replies.

wvandenberg

Technical User
Oct 24, 2002
125
CA
I have two queries:


query1

Code:
SELECT DISTINCT tblImportALS.ANALYTE, tblAnalytes.AnalyteName, tblGroups.GroupDescription, tblReportingUnits.ReportingUnitsDescription, tblAnalytes.pkAnalyteID, tblAnalytes.ParentAnalyteID
FROM tblImportALS INNER JOIN (tblReportingUnits INNER JOIN (tblAnalytes INNER JOIN tblGroups ON tblAnalytes.fkLabGroupID = tblGroups.pkGroupID) ON tblReportingUnits.pkReportingUnitsID = tblAnalytes.fkReportingUnitsID) ON (tblImportALS.UNITS = tblReportingUnits.ReportingUnitsDescription) AND (tblImportALS.PCODE = tblGroups.GroupDescription) AND (tblImportALS.ANALYTE = tblAnalytes.AnalyteName);

query2
Code:
SELECT DISTINCT tblImportALS.ANALYTE, tblAnalytes.AnalyteName, tblGroups.GroupDescription, tblReportingUnits.ReportingUnitsDescription, tblAnalytes.pkAnalyteID, tblAnalytes.ParentAnalyteID
FROM tblImportALS, (tblReportingUnits INNER JOIN tblAnalytes ON tblReportingUnits.pkReportingUnitsID = tblAnalytes.fkReportingUnitsID) INNER JOIN tblGroups ON tblAnalytes.fkLabGroupID = tblGroups.pkGroupID
WHERE (((tblAnalytes.AnalyteName)=[ANALYTE]) AND ((tblGroups.GroupDescription)=[PCODE]) AND ((tblReportingUnits.ReportingUnitsDescription)=[UNITS]));

Both queries produce the same results but I don't know which one is better/faster?

Any suggestions?

Thanks,
Wendy
 
It is my understanding that joins are more efficient in JET and SQL Server. I expect there might be some dependency on indexing of the fields contained in the joins/criteria.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top