将sql转换为dql

nom7f22z  于 2021-08-13  发布在  Java
关注(0)|答案(1)|浏览(339)

我正在努力把它翻译成dql

SELECT SUM(qtestock)
     , (SELECT nom FROM categorie c WHERE c.idcateg=p.idcateg) nom 
  FROM produit p 
 GROUP 
    BY idcateg
pcrecxhr

pcrecxhr1#

我开始在dql,我不知道它是否会帮助你,但我建议你无论如何。首先,我认为最好在查询中使用联接,如:

SELECT SUM(p.qtestock), c.name FROM product p
INNER JOIN category c on(c.idcateg=p.idcateg) 
GROUP BY idcateg

使之更容易。现在我们要把它翻译成dql:

SELECT SUM(p.qtestock), c.name FROM product p
JOIN p.category c 
GROUP BY p.idcateg

有关更多信息,请参阅https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/dql-doctrine-query-language.html

相关问题