Question

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)
Était-ce utile?

La solution

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);
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top