Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

replace NOT IN with JOIN

I need a replacement NOT IN with join . How do I do this because the results are different with this query.

SELECT COUNT(*) as total FROM requests 
        WHERE 
            isApproved='1' AND 
            softDelete='0' AND 
            requestID NOT IN ( 
                SELECT 
                    DISTINCT requestID 
                FROM consulting 
                WHERE 
                    softDelete='0' AND 
                    isApproved='1' AND
            ) 

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

SELECT COUNT(*) as total FROM requests AS R
   LEFT JOIN
   (
      SELECT 
                DISTINCT requestID 
            FROM consulting 
            WHERE 
                softDelete='0' AND 
                isApproved='1' AND
   ) X ON R.requestID =X.requestID 
    WHERE R.isApproved='1' AND R.softDelete='0' 
       AND X.requestID  IS NULL

Could you please try something like this

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading