如何为此类查询构建推进标准:
SELECT * FROM Table1 WHERE id not in (SELECT id FROM Table2 WHERE field1 = 2)
答案 0 :(得分:0)
我找到了解决方案,可以使用Criteria::CUSTOM
,例如:
public static function getElementsWithNotIn(){
$c = new Criteria();
$c->add(Table1Peer::ID, Table1Peer::ID . ' NOT IN (SELECT '. Table2Peer::ID .' FROM '. Table2Peer::TABLE_NAME .')', Criteria::CUSTOM);
return Table1Peer::doSelect($c);
}