有人可以帮助我在学说中引用这个请求
SELECT *, (SELECT CONCAT(NOM, ' ', PRENOM) as nn
FROM BRHM
WHERE NNI = a.`NNI_AFFECTATEUR`) as NOM_PRENOM_AFFECTATEUR
FROM BRHM a
WHERE DATEDIFF(DATE_FIN_ACCES_SI, NOW())<35
ORDER BY PERIMETRES
答案 0 :(得分:0)
我的解决方案
$ repository = $ this-&gt; getDoctrine() - &gt; getRepository('OpfBundle:Entity'); $ query = $ repository-&gt; createQueryBuilder('b') - &gt;选择('b.nni,b.nom,b.prenom,b.nniAffectateur,b.dateDebutAccesSi,b.dateFinAccesSi,b.dateFinFidaa,b.autorisation,b .qualifications,b.perimetres') - &gt; addSelect('CONCAT(b.nom,\'\',b.prenom)为NOM_PRENOM') - &gt; leftJoin('OpfBundle:Entity','rr',Expr \ Join :: WITH,'b.nniAffectateur = rr.nni') - &gt; where('b.nniAffectateur = rr.nni') - &gt; addSelect('CONCAT(rr.nom,\'\',rr.prenom)为NOM_PRENOM_AFFECTATEUR') - &GT; andWhere( 'b.nniAffectateur = rr.nni') - &gt; andWhere('DATE_DIFF(b.dateFinAccesSi,CURRENT_DATE())&lt; 35') - &GT; ORDERBY( 'b.perimetres') - &GT; getQuery(); $ perim = $ query-&gt; getResult();