2016-08-05 62 views
0

我需要建立在查詢生成器,查詢留下查詢建設者

SELECT * FROM table1 LEFT JOIN table2 ON (table1.parent_id = table2.id OR table1.id = table2.id) WHERE table2.id IS NULL; 

我already've得到

$er->createQueryBuilder('p') 
        ->leftJoin('Bundle2:table2', 'n') 
        ->where('p.parent = n.id') 
        ->andWhere('p.id = n.id'); 

,但不知道如何添加外部WHERE外部查詢加盟查詢?

回答

0

試試這個:

return $this->createQueryBuilder('t1') 
     ->leftJoin('t1.table2', 't2') 
     ->where('t1.parent = t2.id OR t1.id = t2.id') 
     ->andWhere('t2.id IS NULL') 
     ->getQuery() 
     ->getResult();