Ok, if you accept using two finds, then you can do it with CakePHP find types.
[code] $offer_locations = $this->Offer->find( 'list', array( 'fields' => array( 'id', 'location_id' ), 'conditions' => array( 'Offer.category_id' => $id ) ) ); $locations = $this->Location->find( 'all', array( 'contain' => array( 'Offer', 'LocationsPicture' ), 'conditions' => array( 'Location.id' => $offer_locations ) ) ); [/code] That will give the same result as yours. By passing the result of the find('list'), which is an array, to the conditions in the find('all'), CakePHP will automatically assume that IN is wanted for the Location.id condition. Hope you find this helpful, and congratulation with you success :) Enjoy, John On Jun 13, 4:24 pm, viciat <viciuasc...@yahoo.com> wrote: > Solution > After reading > this:http://bakery.cakephp.org/articles/view/get-the-find-query-sql-rather... > > First get the id's of the locations from the offers corresponding to a > certain category > > $this->Offer->recursive = 0; > $options = array( > 'conditions' => array( > 'Offer.category_id' => $id), > 'fields' => 'Offer.location_id', > 'recursive' => -1 > ); > $location_ids = > $this->Offer->find("sql",$options); > > Than get the actual locations > $location_options = array( > 'conditions' => array( > 'Location.id IN ('.$location_ids.')' > ), > 'contain' => > array('Offer','LocationsPicture') > ); > > $locations = $this->Location->find('all', > $location_options); > $this->set('locations',$locations); > -- > View this message in > context:http://old.nabble.com/3-models-and-search-condition-tp28866040p288712... > Sent from the CakePHP mailing list archive at Nabble.com. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en