database selection(db_Select)
fetchAssoc fetches a single record as an associative array; you're then looping over that one array and setting a message for the single column in that array, field_cage_id_vbc_target_id. Hence just the one result, an integer instead of the expected array(s).

You can use fetchAllAssoc instead:

$result = $query-&gt;execute()-&gt;fetchAllAssoc();

foreach($result as $record){
  drupal_set_message($record);
}