nameless
nameless

Reputation: 3

How to get row count (from other table) using subquery in propel?

I want to do something like this:

SELECT a.*, (SELECT COUNT(*) FROM b where b.col1 = a.col2) as count FROM a

is it possible using propel criteria or not?

Upvotes: 0

Views: 1861

Answers (1)

$c = new Criteria();
$c->addSelectColumn(aPeer::TABLE_NAME.'.*');
$c->addAsColumn('count', '(SELECT COUNT(*) FROM b WHERE b.col1 = a.col2)');
aPeer::doSelect($c);

Upvotes: 2

Related Questions