Résolu , cette requête a fonctionné pour moi
SELECT messages.* FROM messages, (SELECT MAX(id) as lastid
FROM messages
WHERE (messages.receiver_id = '$myid' OR messages.sender_id = '$myid')
GROUP BY CONCAT(LEAST(messages.receiver_id,messages.sender_id),'.',
GREATEST(messages.receiver_id, messages.sender_id))) as conversations
WHERE id = conversations.lastid
ORDER BY messages.time DESC