SQL - records not in 2nd table
Posted on 2011-02-17
I have a simple 1 to many relationship between 2 tables. table 1 has unique email addresses. table 2 is a history of users based on email address. So i have duplicates in table 2 with a date.
I need to work out which users have NOT loged in between 2 date ranges. I cannot get it working. Here is what i have at the moment. So i need to display users that have not logged into the system say for a specific month
SELECT DISTINCT u.email, h.email AS Expr1
FROM tblUsers u LEFT OUTER JOIN
tblUserHistory H ON u.email = h.email
WHERE (h.createDate >= '2010-07-01') AND (h.createDate <= '2010-07-02 00:00:00')