I have a problem converting the following SQL query to doctrine queryBuilder syntax. I opted for the query builder since I read that inner joins are not possible with DQL(which I am confortable with). Your usual help is appreciated in a time I really have headacke after a lot of searching:
SELECT m.*
FROM `message` AS m
INNER JOIN (SELECT sender_id, MAX(message_date) as md
FROM message WHERE `receiver_id` =1 GROUP BY sender_id) AS t
ON m.id=t.md and m.sender_id=t.sender_id
WHERE `receiver_id` =1
In words, my final goal is to select all the latest messages received by a receiver_id
from a table looking like:
Message(id, sender_id, receiver_id, message_date)