Reputation: 153
I'm using a subquery to calculate certain fields
place_id, count(*) as count, IFNULL(AVG(reviews.rating),0) as value
now I want to be able to select these values but don't seem to find out how, only in a WHERE clause...
Upvotes: 0
Views: 1069
Reputation: 1117
take the ids you will get from this query as an array and put it in a find().
$this->Model->find('all', array('conditions' => array('Model.id' => $list_of_ids);
if you put an array of Ids in a query, cake automatically builds an query with the correct subquery.
Upvotes: 1