update statement using nested query
Something like this?
UPDATE mytable SET lastLogDate = t.maxDateForUser
FROM
(
SELECT userid, MAX(logDate) as maxDateForUser
FROM mytable
GROUP BY userId
) t
WHERE mytable.userid = t.userid
You can do this:
UPDATE t
SET t.logDate = t2.LatestDate
FROM YourTable t
INNER JOIN
(
SELECT userID, MAX(LogDate) LatestDate
FROM YourTable
GROUP BY userID
) t2 ON t.userID = t2.userID;
I don’t know if I understood you correctly. Otherwise be a bit more specific, but from what I get, you should do something along the lines of:
UPDATE `mytable`
SET lastLogDate = (SELECT statement goes here)
WHERE ...