Jump to content
Server Maintenance This Week. ×

NOT EXISTS


This topic is 3089 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi all

I'm trying to utilise the NOT EXISTS command:

I need to find records in the Cases table that do not have matching records in the Originals table.

So far I have:

SELECT a.Case_ID
FROM Cases a
WHERE a.Closed IS NULL 
AND
NOT EXISTS
    (SELECT * 
     FROM Originals b
     WHERE b.Case_IDF = a.Case_ID)

            
It just freezes when I try this though. Could it be that because there are a lot of records in each table? I will be using additional criteria - not sure if this would improve performance if this is the case.


Any help appreciated.

Thanks

Link to comment
Share on other sites

Have got a script trigger to set a flag field in the parent table if no records existing in the child table, then just use a simpler SQL command. It took far too long to do it all in SQL.


Cheers guys

Link to comment
Share on other sites

This topic is 3089 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.