0

I created a query in SQL but I don't know hos to reproduce with doctrine. The difficulties, I would like to join on 2 values in a subquery. Here my SQL query :

SELECT u.nom FROM profile p1 JOIN user u ON u.id = p1.id_user JOIN ( SELECT MAX(p2.annee) defyear, p2.id_user FROM profile p2 GROUP BY p2.id_user ) t2 ON p1.id = t2.id_user AND p1.annee = t2.defyear WHERE p1.att1 = 1

Thank you for your help.

1 Answers1

0

From what I've found so far you cannot JOIN on subqueries with Querybuilder. You can however use NativeSQL as I understand.

See the thread: https://groups.google.com/d/msg/doctrine-user/0rNbXlD0E_8/xMNiQgp9c3QJ

and NativeQueries on: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/native-sql.html

Hope this helps!