Rush_2112
asked on
Query runs too slowly
Here's the query:
SELECT *
FROM NC2 a LEFT OUTER JOIN Actions b ON a.UniqueID = b.DealerID
WHERE NOT EXISTS (
SELECT c.DealerID
FROM Actions c
WHERE c.DealerID = b.DealerID
AND c.EventID = 1
)
It works, but it can take over a minute to return records. The 2 tables only have a few hundred records each.
What I need it to do is the following:
Select every record in NC2 UNLESS the value of UniqueID in NC2 matches up with a field called DealerID in a table called Actions., and then only if they match and the EventID is equal to 1.
Thanks
SELECT *
FROM NC2 a LEFT OUTER JOIN Actions b ON a.UniqueID = b.DealerID
WHERE NOT EXISTS (
SELECT c.DealerID
FROM Actions c
WHERE c.DealerID = b.DealerID
AND c.EventID = 1
)
It works, but it can take over a minute to return records. The 2 tables only have a few hundred records each.
What I need it to do is the following:
Select every record in NC2 UNLESS the value of UniqueID in NC2 matches up with a field called DealerID in a table called Actions., and then only if they match and the EventID is equal to 1.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER