SELECTing multiple columns through a subquery
SELECT DISTINCT petid, userid, lastComDate, lastPosterId
FROM 
    pet 
    LEFT JOIN comments ON pet.id = comments.petid 
    LEFT JOIN (
        SELECT MAX(comDate), userid, petid FROM comments GROUP BY userid
    ) a ON a.petid = pet.id
WHERE 
    userid='ABC' 
    AND deviceID!='ABC' 
    AND comDate&gt;=DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 2 MONTH)
;


You can also pull your subquery out into a temp table if performance becomes impacted somewhere down the road.