$data = $db->query_first("SELECT postid, MAX(dateline) FROM post WHERE dateline > " . $vbulletin->userinfo['lastvisit'] . " AND forumid = $forumid");
Please not, these are example queries, i'm not totally sure they'll work, though they should and there could be a cheaper way to do it, these are just off the top of my head.