SQL query problem
        Posted  
        
            by Pankaj
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Pankaj
        
        
        
        Published on 2010-05-25T09:36:39Z
        Indexed on 
            2010/05/25
            9:41 UTC
        
        
        Read the original article
        Hit count: 307
        
mysql
Hello All
I have 2 tables Project and ProjectList like this
Project
ProjectID
Name
ProjectListID - allow null
In ProjectList
ProjectListID
ProjName
Now what i need here, i want only those recoed from ProjectList table which ProjectListID not in Project table. I made a query but it is taking lot of time to execute.
select * FROM projectslist pl where pl.ProjectsListID not in (SELECT p.ProjectsListID FROM project p where (p.ProjectsListID is not null and p.ProjectsListID <>0))
Please help me to create optimize query. I am using My SQL.
© Stack Overflow or respective owner