I am trying to get relation where `companies` table have primary key `companyID` and `division` table have Foreign key `companyID` , what I need in where clause is `WHERE companies.companyID = division.companies`
relation in my model is :

```
public function relations()
    {
        return array(
            'company' => array(self::BELONGS_TO, 'Companies', 'CompanyID'),
        );
    }

```

My `Model->search()` function is 

```
public function search()
{
    $criteria=new CDbCriteria;
    $criteria->with ='company';
    $criteria->compare('company.CompanyID', $this->CompanyID, true );
    $criteria->compare('DivisionID',$this->DivisionID, true);
    $criteria->compare('CompanyID',$this->CompanyID, true);
    $criteria->compare('Name',$this->Name,true, true);

    return new CActiveDataProvider($this, array(
        'criteria'=>$criteria,
    ));
}

```

and my `admin.php` view is:

```
 <?php
$this->breadcrumbs = array(
    'Divisions' => array('index'),
    'Manage',
);

$this->menu = array(
    array('label' => 'List Divisions', 'url' => array('index')),
    array('label' => 'Create Divisions', 'url' => array('create')),
);

   ");
?>

<div class="row">
    <?php
    $this->renderPartial('_dropdownfilter', array(
        'model' => $model,
    ));
    ?>
</div><!-- end dropdown partial form -->
<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'divisions-grid',
    'dataProvider' => $model->search(),
    'filter' => $model,
    'columns' => array(
        'CompanyID',
        'DivisionID',
        'Name',
        array(
            'class' => 'CButtonColumn',
        ),
    ),
));
?>

```