문제

How can i build a propel criteria for this type of query:

SELECT * FROM Table1 WHERE id not in (SELECT id FROM Table2 WHERE field1 = 2)
도움이 되었습니까?

해결책

I found the solution, it's possible by using Criteria::CUSTOM, for example:

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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top