Mysql 信条-不等于某种价值

Mysql 信条-不等于某种价值,mysql,select,doctrine-orm,Mysql,Select,Doctrine Orm,我想检测不等于1,2,3或NULL的id。我的问题是: $qb = $this->_em->createQueryBuilder() ->select('u.cityId') ->from('.....\Entities\Cities', 'u') ->where("u.cityId is null OR u.cityId NOT IN (:parentType) ") ->setParameter('parentType' ,

我想检测不等于1,2,3或NULL的id。我的问题是:

$qb = $this->_em->createQueryBuilder()
    ->select('u.cityId')
    ->from('.....\Entities\Cities', 'u')
    ->where("u.cityId is null OR u.cityId NOT IN (:parentType) ")
    ->setParameter('parentType' , "2,3,10");
$qb = $qb->getQuery();
return $qb->getResult();

尽管它向我显示的id为NULL或不等于2和其他值。这不是限制3,10。有什么建议吗?

您需要传递一个数组。试试这个:

->setParameter('parentType' , array(2,3,10) );
而不是:

->setParameter('parentType' , "2,3,10");
希望这有帮助