Join or Subquery? Is there another more efficient way of doing this [message #242277] |
Fri, 01 June 2007 08:10 |
fmrock
Messages: 45 Registered: December 2006
|
Member |
|
|
Is there a more efficent way of doing this instead of a using an exists
This table would be called tblComments. And basicly, I want to find all accounts that do not have a the text "XYZ". They could have many comments, and if "XYZ" is in any one of them, I dont want it to show on the report.
I have this created already with an exists statement, but looking to possible make it more efficient with a join.
The query before checking the comments table has around 45K accounts that match.
AND NOT exists(
SELECT distinct r.location, r.accountnum
FROM tblComments mr
WHERE d.location = r.location
AND d.accountnum = r.accountnum
AND r.comment LIKE '%XYZ%'
)
This report does work, but it takes a while to run as you can imagine.
[Updated on: Fri, 01 June 2007 08:25] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|