Monster of a SQL Query Problem
Posted: Mon Jul 16, 2007 9:37 am
Ok. I have this query to return all user logins from a transaction_log. Is it possible to get the last login from the log and update the users table to set the account as inactive ie active =0
Thanks to volka i got this to return the last login time for all users. Now, how do i update the users table from this last login time.
Thanks to volka i got this to return the last login time for all users. Now, how do i update the users table from this last login time.
Code: Select all
SELECT
a.user_id,u.username,u.email,u.firstname,u.surname,u.active, a.logtime
FROM
transaction_log AS a
LEFT JOIN
transaction_log AS b
ON
a.user_id=b.user_id
AND a.logtime<b.logtime
JOIN
users AS u
ON
u.id=a.user_id
WHERE
b.logtime IS NULL
AND u.guest = 1