Can someone provide a little help on this?
I am trying to get a DISTINCT field from one table based on another table's value.
public function getActiveStates(){
$params = array(
'contain' => 'Community',
'conditions' => array(
'Community.status' => array('Active','Pending')),
'fields' => array(
'DISTINCT State.name'));
return $this->find('list', $params);
}
I am trying to get the DISTINCT State.name based on the Community table based on the Community.status so end up with a list like Alaska, Georgia, Illinois….. and so on
They do have a Community belongsTo <-> State hasMany all set up
Thanks,
Dave
No comments:
Post a Comment