Thanks for the input! That is close to what I need, however not exactly. It
will give me the last time a user logged into the host in question but I
want to prune users who have since logged into a different host. Basically
find out how many users are logged into a given host or who are not
currently logged in but have not logged into a different host since they
logged out of the target. 

For perspective the host is a wireless access point with fixed clients. A
host that hasn't logged in somewhere else we can (somewhat) safely assume is
still pointed at the AP in question but is power off, or has its connection
interrupted for some other reason. If they have logged in somewhere else we
assume that the hardware was moved to a new location and installed there. 

The query I came up with for some reason doesn't seem to correctly order the
dates so if they have logged into the host in question the information is
returned. This produces too many results as some of those users have since
migrated to a different access point.

-----Original Message-----
From: Andrew Wallo [mailto:theme...@microneil.com] 
Sent: Tuesday, February 10, 2009 12:05 PM
To: Ben Wiechman
Subject: Re: Query Help


Select login, SQL MAX(DateTime) from Log groupby Log.Login ( Gives you the 
most recent login for a user - on any host. )

Select login, SQLMax(DateTime) from Log groupby Log.Login, Host ORDER BY 
HOST ASC, DATETIME DESC

(Should give you the largest, i.e. most recent, date for each user on each 
host, oganized by host, in descending login order..... I think... )



----- Original Message ----- 
From: "Ben Wiechman" <b...@meltel.com>
To: <mysql@lists.mysql.com>
Sent: Tuesday, February 10, 2009 12:31 PM
Subject: Query Help


>I keep hacking at this but haven't been able to get it right yet.
>
>
>
> I have two tables
>
> Userinfo contains a login, User's Name, Group Name
>
> Log contains login, host, datetime of last login
>
>
>
>
>
> What I need to do is return user information (userinfo.name/groupname) of
> users that have logged into a particular host last. i.e. A user can log 
> into
> any of the hosts but I want to know which one they were on last. Each time
> they log the username, host and datetime of login are recorded in the log
> table. I've been able to return the last login to the host but I'm at a 
> loss
> to get the list of all users that used the host last or all users that 
> have
> ever logged into that host.
>
>
>
>
>
> 





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to