Pregunta

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)
¿Fue útil?

Solución

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);
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top