Hello

I have a User entity (id, firstname, lastname) and an entity Profile (id, 
id_user, year, att1, att2) 
Between two entity I have a OneToMany relationship with one user can have N 
Profile 
The Profile is the profile of the user with only 1 year. 
I would make a request on the value att1 = 1, but only the most recent of 
each user profiles. 
In SQL I have done like this:

SELECT u.nomFROM profile p1JOIN user u ON u.id = p1.id_userJOIN (
    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.defyearWHERE p1.att1 = 1


I have a subquery in the join to select only the max profile year on each 
user
And I match the result on user_id AND definition_year.
How I can do that with doctrine ?

Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to