UPDATE cms
SET    CurrentLoginTime = mlt,
       LastLoginTime = mlt
FROM   CmsUserTbl cms
       JOIN (SELECT u.cmsuserid,
                    Max(logintime) mlt
             FROM   UserLoginsSuccess l
                    JOIN CmsUserTbl u
                      ON u.cmsusername = l.username
             GROUP  BY u.cmsuserid) t
         ON t.cmsuserid = cms.cmsuserid ;