I have a problem with the SQL statement detailed below. The query returns the results I need, but takes an insane amount of time to execute. I now have so many records in the db that the page generally won't load.
SELECT dscan.guid, dscan.drive, dscan.folder, dscan.filename, source.guid
FROM source
RIGHT JOIN dscan ON (
(source.guid & '_dtr' = dscan.guid OR source.guid & '_dto' = dscan.guid OR source.guid = dscan.guid)
AND dscan.guid LIKE '%" & Replace(strSearch_guid, "'", "''") & "%'
AND dscan.filename NOT LIKE '.[_]%'
AND dscan.drive = 'Z:')
WHERE source.guid Is Null
ORDER BY dscan.drive, dscan.guid
From what I've been able to find online, ORs in JOIN statements are a problem, but I can't figure out how to fix this.
I'm comparing database records against filenames to identify errors - but the filenames sometimes have '_dtr' or '_dto' appendages that I have to take into consideration.