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>=DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 2 MONTH)
;
|
|
Tidak ada komentar:
Posting Komentar