My code :
$criteria = new CDbCriteria();
//  $criteria->select = array("id");
$criteria->with = array('userProfiles'=>array(
    'select'=>'firstname'
));
$criteria->together = true;
$criteria->condition = "firstname like '%$q%' "
        . "and (user_id not in (select id2 from friends where id1=$user_id) "
        . "and user_id not in (select id1 from friends where id2=$user_id))";
$dataProvider = new CActiveDataProvider("Users", array(
    'criteria' => $criteria
));
return $dataProvider;
Notes:
1- userProfiles relation is defined in User module
Issue:
It is loading data only from User table not also from the user_profiles table despite of providing select atribute 'select'=>'firstname'
I want data from both user and userProfile table.