i'm struggling in translating this to dql
SELECT SUM(qtestock)
, (SELECT nom FROM categorie c WHERE c.idcateg=p.idcateg) nom
FROM produit p
GROUP
BY idcateg
i'm struggling in translating this to dql
SELECT SUM(qtestock)
, (SELECT nom FROM categorie c WHERE c.idcateg=p.idcateg) nom
FROM produit p
GROUP
BY idcateg
I'm starting on the DQL, I don't know if it will help you but I propose you anyway. First, I think it would be better to use a join in your query like:
SELECT SUM(p.qtestock), c.name FROM product p
INNER JOIN category c on(c.idcateg=p.idcateg)
GROUP BY idcateg
to make it easier. Now we're gonna translate it into DQL:
SELECT SUM(p.qtestock), c.name FROM product p
JOIN p.category c
GROUP BY p.idcateg
for more information, please refer to https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/dql-doctrine-query-language.html