我需要在查询构建器
中创建该查询SELECT * FROM table1 LEFT JOIN table2 ON (table1.parent_id = table2.id OR table1.id = table2.id) WHERE table2.id IS NULL;
我已经
了$er->createQueryBuilder('p')
->leftJoin('Bundle2:table2', 'n')
->where('p.parent = n.id')
->andWhere('p.id = n.id');
但不知道如何添加外部WHERE来查询?
答案 0 :(得分: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();