[thelist] MySQL - selecting records that are NOT in a date range...

Jason Handby jason.handby at corestar.co.uk
Tue Nov 20 04:27:26 CST 2007

> Iv'e got a table of activitives on a site.
> I want to pull all user Ids of users who have NOT been logged 
> in sept 07.
> So I need to have my daterange (unix timestamp)
> SELECT `UserId` FROM `activities` WHERE `Timestamp` > '1191196799' AND
> `Timestamp` < '1188604800' GROUP BY `UserId`
> But how can I say to MySQL: get me all users who DON'T have entries in
> this range...
> i can find 101 tutorials on how to get dates within a range, but not
> the other way around...
> Thoguhts?


SELECT `UserId` FROM `activities` WHERE NOT (`Timestamp` > '1191196799'
`Timestamp` < '1188604800') GROUP BY `UserId`


More information about the thelist mailing list