[thelist] Last Login Time SQL

Jay Blanchard jblanchard at pocket.com
Tue Jan 9 14:02:50 CST 2007


[snip]
I'm trying to come up with an SQL statement that will return all of the 
users who haven't logged in to a system in 90 days or more. I can get 
the information I need with a nested query, but given that there are a 
lot of records, it's pretty slow and inefficient. There must be a good 
way to do it, but I'm not fluent enough in SQL to figure it out.

The details: I have two tables, one of which, "users", stores typical 
user data (user_id, user_name, password, email) and the other, 
"user_log" just records logins (user_id, login_time). I need to get a 
list of all the user_names of people whose most recent login_time is 90 
days or more before right now.

This is classic ASP querying Access, but if anyone has any ideas in 
reasonably generic SQL, I can translate as necessary.
[/snip]

SELECT * FROM logins WHERE login_time DATE_SUB(login_time, INTERVAL 90
DAY) 



More information about the thelist mailing list