Jump to content

Find a User not in another table for specified dates


jbradley04

Recommended Posts

Hello all,

 

I am trying to find a user that is NOT IN another table.  Here is the code I have but it is not working.  Any help would be greatly appreciated!

select * from user as u, 
where u.GroupID=9 and 
u.ID NOT IN (SELECT CBy FROM stories WHERE Con BETWEEN '2014-07' AND '2015-07' AND CBy IS NOT NULL)

Thanks for the help!

Joins are usually more efficient

SELECT *
FROM USER u
LEFT JOIN stories s
    ON u.ID = s.CBy AND s.con BETWEEN '2014-07' AND '2015-07'
WHERE s.CBy IS NULL

BTW, you shouldn't have had the comma at the end of your first line

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.