Drupal db_or() only returning one result Can someone please tell me why this code always returns only the last value of the query? I have tried many ways to dynamically build the condition statement for the querying of the database. I have looked at a couple examples and from everything i have seen, this is the way to do it. Any help would be greatly appreciated. Thanks!

function get_drupal_school_info($schoolIds) {
$or = db_or();
foreach ($schoolIds as $index =&gt; $data){
$or-&gt;condition(db_and()
    -&gt;condition('f.field_external_id_value', $data['entity_id'],'=')
    -&gt;condition('f.bundle', 'school')
    );
}       

$query = db_select('field_data_field_external_id', 'f');
$query-&gt;leftJoin('field_data_body', 'b', 'f.entity_id = b.entity_id');
$query-&gt;leftJoin('field_data_field_partner_code', 'pc', 'b.entity_id = pc.entity_id');
$query
    -&gt;fields('f', array('entity_id'))
    -&gt;fields('b',array('body_value'))
    -&gt;fields('pc',array('field_partner_code_value'))
    -&gt;condition($or);

return $query-&gt;execute()-&gt;fetch();
}
It's, because you are calling fetch(). That method fetches a single result.

If you want all, you can simply loop over the return value of $query->execute() or use fetchAll() or one of the many related helper functions.