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

Rewrite SQL to make query faster?

Status
Not open for further replies.

wvandenberg

Technical User
Oct 24, 2002
125
CA
Morning,

I have this query that works correctly.
Code:
INSERT INTO tblWizTempALS ( SAMPLENUM, CLIENTID, MATNUM, SMPDATE, PCODE, METHOD, ANALYTE, RESULT, ResultFixed, Symbol, UNITS, QUALIFIER, RComments )
SELECT tblWizTempWDS.SAMPLE_NO, tblWizTempWDS.STATION_NO, tblWizTempWDS.SAMPLE_MATRIX_CODE, tblWizTempWDS.SAMPLE_DATETIME, tblWizTempWDS.VARIABLE_GROUP_NAME, tblWizTempWDS.VARIABLE_CODE, tblWizTempWDS.VARIABLE_NAME, tblWizTempWDS.MEAS, tblWizTempWDS.ResultFixed, tblWizTempWDS.Symbol, tblWizTempWDS.UNIT_CODE, tblWizTempWDS.QC_SAMPLE_FLAG, tblWizTempWDS.MEASUREMENT_ID
FROM tblWizTempWDS LEFT JOIN [SELECT tblResults.Comments
        FROM tblSites INNER JOIN (tblSamples INNER JOIN tblResults ON tblSamples.pkSampleID = tblResults.fkSampleID) ON tblSites.pkSiteID = tblSamples.fkSiteID
        WHERE (((tblSites.SiteName) Like "AB0" & "*"))]. AS A ON tblWizTempWDS.MEASUREMENT_ID = A.Comments
WHERE (((A.Comments) Is Null));
I was just wondering if anyone had any suggestions on how I could rewrite the SQL to speed up the query. Any advice is appreciated.

Thanks,
Wendy
 
As far as I recall Like is slower than equals, so perhaps:

Left(tblSites.SiteName,3) = "AB0"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top