SELECT datee, timee, host, logname, methodr, url, find, replacee, code, bytesd, other, ua, referer FROM dbo.testlog INNER JOIN dbo.testcluster ON SUBSTRING(dbo.testcluster.find, 1, LEN(dbo.testcluster.find) - 1) = SUBSTRING(dbo.testlog.url, 1, LEN(dbo.testcluster.find) - 1) WHERE dbo.testcluster.find Like '%*' or dbo.testcluster.find = dbo.testlog.url;