title: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'name' in where clause is ambiguous .. Yii2
body: <p>Here i ran into this below error while am trying to search in Yii2 gridview</p>
  
  <pre><code>SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'name' in where clause is ambiguous
  The SQL being executed was: SELECT COUNT(*) FROM `leagues` LEFT JOIN `country` ON 
  `leagues`.`country_id` = `country`.`id` WHERE `name` LIKE '%Eredivisie%'
  </code></pre>
  
  <p>the below sql code was generated by Yii, so i don't know how to the causes of the sql error or how to manipulate it. Below is my search model that shows the relations between the two table</p>
  
  <pre><code>&lt;?php
  
  namespace backend\models;
  
  use yii\base\Model;
  use yii\data\ActiveDataProvider;
  use backend\models\League;
  
  
  class LeagueSearch extends League
  {
      /**
       * {@inheritdoc}
       */
          public function rules()
  
  
    {
          return [
             [['id', 'created_at', 'updated_at'], 'integer'],
             [['name','country_id'], 'safe'],
         ];
      }
  
  /**
   * {@inheritdoc}
   */
  public function scenarios()
  {
      // bypass scenarios() implementation in the parent class
      return Model::scenarios();
  }
  
  /**
   * Creates data provider instance with search query applied
   *
   * @param array $params
   *
   * @return ActiveDataProvider
   */
  public function search($params)
  {
      $query = League::find();
  
  
      $query-&gt;joinWith('country');
      // add conditions that should always apply here
  
      $dataProvider = new ActiveDataProvider([
          'query' =&gt; $query,
          'sort'=&gt; ['defaultOrder' =&gt; ['name' =&gt; SORT_ASC]],
      ]);
  
      $this-&gt;load($params);
  
      if (!$this-&gt;validate()) {
          // uncomment the following line if you do not want to return any records when validation fails
          // $query-&gt;where('0=1');
          return $dataProvider;
      }
  
      // grid filtering conditions
      $query-&gt;andFilterWhere([
          'id' =&gt; $this-&gt;id,
          'created_at' =&gt; $this-&gt;created_at,
          'updated_at' =&gt; $this-&gt;updated_at,
      ]);
  
      $query-&gt;andFilterWhere(['like', 'name', $this-&gt;name])
            -&gt;andFilterWhere(['like', 'country.name',$this-&gt;country_id]);
  
      return $dataProvider;
  }
  }
  </code></pre>
  
  <p>name is a column in league table, country is also having a column called name so i think sql is missing up something here. Any help on this will be appreciated</p>