newfrontiers
Programmer
Hello. I have been trying, unsuccessfully for 2 days now, to improve the performance of the following query:
SELECT C.No, C.BusName, C.SecBusName, C.City, C.State , C.ProspectSt , C.Sales , C.EmpTotal, tblContacts.chrFName, tblContacts.chrLName, tblLastLookup.dteLastLookup, tblLastLookup.chrUserid FROM (C LEFT JOIN tblLastLookup ON C.[No] = tblLastLookup.intNo) LEFT JOIN tblContacts ON C.[No] = tblContacts.[No] WHERE ((C.[No]) IN (SELECT DISTINCT C.[No] FROM C LEFT JOIN tblSIC ON C.[No] = tblSIC.[No] WHERE ((State='NY' AND County IN ('Rensselaer'))) AND (Primsic LIKE '6411*') ) AND ( ((C.BusName) Like 'a*' OR C.SecBusName Like 'a*') AND ((tblContacts.chrLName) Like 'pop*') AND ((C.ProspectSt) Like 'Hot*')))
Is the problem that the subquery and main query use the same table?
Thanks for any assistance as I have a bad headache from banging my head against the wall.
SELECT C.No, C.BusName, C.SecBusName, C.City, C.State , C.ProspectSt , C.Sales , C.EmpTotal, tblContacts.chrFName, tblContacts.chrLName, tblLastLookup.dteLastLookup, tblLastLookup.chrUserid FROM (C LEFT JOIN tblLastLookup ON C.[No] = tblLastLookup.intNo) LEFT JOIN tblContacts ON C.[No] = tblContacts.[No] WHERE ((C.[No]) IN (SELECT DISTINCT C.[No] FROM C LEFT JOIN tblSIC ON C.[No] = tblSIC.[No] WHERE ((State='NY' AND County IN ('Rensselaer'))) AND (Primsic LIKE '6411*') ) AND ( ((C.BusName) Like 'a*' OR C.SecBusName Like 'a*') AND ((tblContacts.chrLName) Like 'pop*') AND ((C.ProspectSt) Like 'Hot*')))
Is the problem that the subquery and main query use the same table?
Thanks for any assistance as I have a bad headache from banging my head against the wall.