我正在尝试将以下查询转换为dql:
SELECT cm.*
FROM conversation__conversation cc
INNER JOIN conversation__message cm
ON cm.conversation_id = cc.id
INNER JOIN vehicle__vehicle vv
ON vv.id = cc.vehicle_id
WHERE (cc.driver_id = 25 OR vv.owner_id = 25)
AND cm.id in (SELECT m1.id
FROM conversation__message m1
LEFT JOIN conversation__message m2
ON m1.conversation_id = m2.conversation_id AND m1.id < m2.id
WHERE m2.id IS NULL)
ORDER BY cm.created_at DESC;
我在此查询中看到两个主要困难。第一个是你有一个subselect,但我已经检查了如何在dql中执行它,但真正困难的部分是使用相同的表进行左连接。我不能让它工作......谁知道该怎么做?