title: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous Yii2
body: <p>Helo, could someone explain me why I'm getting this error? What I was doing is that I'm trying to filter my <code>GridView</code> according to the <code>id's</code>, but it displays this error message. I've tried to search related information, but couldn't find what would be useful. </p>
  
  <p>Here is my <code>Search</code> function:</p>
  
  <pre><code>    public function search($params)
  {
      $query = Sale::find();
  
      $dataProvider = new ActiveDataProvider([
          'query' =&gt; $query,
      ]);
  
      $query-&gt;joinWith('item');
      $dataProvider-&gt;setSort([
          'attributes' =&gt; [
              'id',
              'customer_name',
              'customer_surname',
              'customer_phone',
              'customer_email',
              'code',
              'comment',
              'sign',
              'price' =&gt; [
                  'asc' =&gt;['item.price' =&gt; SORT_ASC],
                  'desc' =&gt;['item.price' =&gt; SORT_DESC],
              ],
              'item_id' =&gt; [
                  'asc' =&gt;['item.name' =&gt; SORT_ASC],
                  'desc' =&gt;['item.name' =&gt; SORT_DESC],
              ]
          ]
      ]);
  
      $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,
      ]);
  
      $query-&gt;andFilterWhere(['like', 'customer_name', $this-&gt;customer_name])
          -&gt;andFilterWhere(['like', 'item.name', $this-&gt;item_id])
          -&gt;andFilterWhere(['like','sign', $this-&gt;sign])
          -&gt;andFilterWhere(['like', 'customer_surname', $this-&gt;customer_surname])
          -&gt;andFilterWhere(['like', 'customer_phone', $this-&gt;customer_phone])
          -&gt;andFilterWhere(['like', 'customer_email', $this-&gt;customer_email])
          -&gt;andFilterWhere(['like', 'code', $this-&gt;code])
          -&gt;andFilterWhere(['like', 'comment', $this-&gt;comment]);
  
      return $dataProvider;
  }
  </code></pre>
  
  <p>It should work, because <code>id</code> has been added to <code>setSort()</code> and <code>filter</code> statements... Thank you for any help</p>