我只想知道如何在doctrine2
中做这样的事情select
e
from
\Entity e
where
e.field1, e.field2 NOT IN (select e2.field1, e2.field2 from \Entity e2 where condition )
当我这样做或者用括号括起两个字段时,我得到了一个错误:
QueryException:[语法错误]第0行,第136行:错误:预期 Doctrine \ ORM \ Query \ Lexer :: T_CLOSE_PARENTHESIS,得到','
或:
QueryException:[语法错误]第0行,第135行:错误:预期=,<, < =,<&gt ;,>,> =,!=,得到','
PHP代码:
$query = $this->_em->createQuery('
SELECT r FROM LibrairieBundle\Entity\Reseau r
WHERE ( r.client1 = :me or r.client2 = :me ) and r.confirme = 1
and (r.client2, r.client1) not in (
select s.clientFrom, s.clientObject from LibrairieBundle\Entity\SuggestClient s
where s.clientTo = :cible
)
');
答案 0 :(得分:1)
将where子句分开。
SELECT
e
FROM
\Entity e
WHERE
e.field1 NOT IN (SELECT e2.field1 FROM \Entity e2 WHERE condition ) AND
e.field2 NOT IN (SELECT e3.field2 FROM \Entity e3 WHERE condition )