Problem with symfony query 3

0

I have the following situation, I have 3 tables. On the one hand I have a list of members, a list of charges and another table that shows the charges that each member has had in different years. What I need is to show a view with the list of members with their current positions, that is, the last position assigned to them. Development in symfony 3 and I need some query in dql or querybuilder to visualize what I need. I show you the tables with sample data and how it should look.

    
asked by Jesús Soto Mitjans 28.06.2018 в 21:45
source

1 answer

0

Taking into account the structure of the tables you propose, the query would be:

SELECT m.nombre,c.descripcion,cm.fecha_ini
FROM miembro AS m
    JOIN cargos_miembros AS cm
        ON m.id = cm.id_miembro
    JOIN cargos AS c
        ON cm.id_cargo = c.id
WHERE cm.id IN (
    SELECT MAX(cm.id) FROM cargos_miembros AS cm
    GROUP BY cm.id_miembro
)
    
answered by 28.06.2018 / 23:43
source