title: Yii2 right join only returning 2 columns
body: <p>Working on an API and I have this query:</p>
  
  <pre><code>$query = CallerIdentity::findNonGeo()-&gt;join( 'RIGHT JOIN', 'ehadata', 'caller_ids.cidref = ehadata.cidref')
              -&gt;select('ehadata.*')
              -&gt;where(['caller_ids.cidref' =&gt; $id]);
  
          echo $query-&gt;getSQL();die;
  </code></pre>
  
  <p>The output of the ->getSQL() function is: </p>
  
  <pre><code>SELECT `ehadata`.* FROM `caller_ids` RIGHT JOIN `ehadata` ON caller_ids.cidref = ehadata.cidref WHERE `caller_ids`.`cidref`='256'
  </code></pre>
  
  <p>and the result of running the query through the function in postman returns: </p>
  
  <pre><code>{
  "cidref": 256,
  "status": 0
  }
  </code></pre>
  
  <p>However when I run the query in adminer the result is:</p>
  
  <p><a href="https://i.stack.imgur.com/qfem9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qfem9.png" alt="Result from adminer"></a></p>
  
  <p>Has anyone got any idea why this might be? I am well and truly confused. Any help is massively appreciated. </p>
  
  <p>EhaData model </p>
  
  <pre><code>class EHAData extends \yii\db\ActiveRecord
  {
  /**
   * @inheritdoc
   */
  public static function tableName()
  {
      return 'ehadata';
  }
  
  /**
   * @inheritdoc
   */
  public function rules()
  {
      return [
          [['cidref', 'status', 'name', 'premesis', 'thoroughfare', 'locality', 'postcode'], 'required'],
          [['cidref', 'status'], 'integer'],
          [['modified'], 'safe'],
          [['title', 'forename', 'postcode'], 'string', 'max' =&gt; 20],
          [['name', 'bussuffix'], 'string', 'max' =&gt; 50],
          [['premesis'], 'string', 'max' =&gt; 60],
          [['thoroughfare'], 'string', 'max' =&gt; 55],
          [['locality'], 'string', 'max' =&gt; 30],
          [['cidref'], 'exist', 'skipOnError' =&gt; true, 'targetClass' =&gt; CallerIdentity::className(), 'targetAttribute' =&gt; ['cidref' =&gt; 'cidref']],
      ];
  }
  
  /**
   * @inheritdoc
   */
  public function attributeLabels()
  {
      return [
          'ehaid' =&gt; 'Ehaid',
          'cidref' =&gt; 'Cidref',
          'status' =&gt; 'Status',
          'title' =&gt; 'Title',
          'forename' =&gt; 'Forename',
          'name' =&gt; 'Name',
          'bussuffix' =&gt; 'Bussuffix',
          'premesis' =&gt; 'Premesis',
          'thoroughfare' =&gt; 'Thoroughfare',
          'locality' =&gt; 'Locality',
          'postcode' =&gt; 'Postcode',
          'modified' =&gt; 'Modified',
      ];
  }
  
  /**
   * @return \yii\db\ActiveQuery
   */
  public function getCallerIdentity()
  {
      return $this-&gt;hasOne(CallerIdentity::className(), ['cidref' =&gt; 'cidref']);
  }
  }
  </code></pre>
  
  <p>Caller Identity model </p>
  
  <pre><code>class CallerIdentity extends \yii\db\ActiveRecord
  {
  
  /**
   * @inheritdoc
   */
  public static function tableName()
  {
      return 'caller_ids';
  }
  
  /**
   * @inheritdoc
   */
  public function rules()
  {
      return [
          [['custref', 'caller_id', 'start_date'], 'required'],
          [['custref', 'status', 'target_index'], 'integer'],
          [['type', 'conf_call', 'magrathea', 'outbound_only', 'callrec_outbound', 'callrec_inbound'], 'string'],
          [['start_date', 'last_polled', 'last_modified', 'created'], 'safe'],
          [['caller_id'], 'string', 'max' =&gt; 15],
          [['location', 'destination', 'redirect'], 'string', 'max' =&gt; 120],
          [['country_code'], 'string', 'max' =&gt; 3],
          [['details'], 'string', 'max' =&gt; 180],
          [['expiry'], 'string', 'max' =&gt; 18],
          [['custref'], 'exist', 'skipOnError' =&gt; true, 'targetClass' =&gt; Customer::className(), 'targetAttribute' =&gt; ['custref' =&gt; 'custref']],
      ];
  }
  
  /**
   * @inheritdoc
   */
  public function attributeLabels()
  {
      return [
          'cidref' =&gt; 'Cidref',
          'custref' =&gt; 'Custref',
          'caller_id' =&gt; 'Caller ID',
          'location' =&gt; 'Location',
          'destination' =&gt; 'Destination',
          'redirect' =&gt; 'Redirect',
          'type' =&gt; 'Type',
          'conf_call' =&gt; 'Conf Call',
          'magrathea' =&gt; 'Magrathea',
          'outbound_only' =&gt; 'Outbound Only',
          'callrec_outbound' =&gt; 'Callrec Outbound',
          'callrec_inbound' =&gt; 'Callrec Inbound',
          'country_code' =&gt; 'Country Code',
          'details' =&gt; 'Details',
          'status' =&gt; 'Status',
          'start_date' =&gt; 'Start Date',
          'expiry' =&gt; 'Expiry',
          'target_index' =&gt; 'Target Index',
          'last_polled' =&gt; 'Last Polled',
          'last_modified' =&gt; 'Last Modified',
          'created' =&gt; 'Created',
      ];
  }
  
  /**
   * @return \yii\db\ActiveQuery
   */
  public function getCustref()
  {
      return $this-&gt;hasOne(Customer::className(), ['custref' =&gt; 'custref']);
  }
  
  /**
   * @return \yii\db\ActiveQuery
   */
  public function getEhadata()
  {
      return $this-&gt;hasMany(EHAData::className(), ['cidref' =&gt; 'cidref']);
  }
  
  /**
   * @inheritdoc
   * @return BanQuery the active query used by this AR class.
   */
  public static function find()
  {
      $query = new CallerIdentityQuery(get_called_class());
  
      $query-&gt;select([
          'caller_ids.cidref','custref', 'caller_id', 'expiry', 'conf_call',
          'type', 'redirect', 'destination', 'caller_ids.status', 'start_date',
          'statusDesc' =&gt; new \yii\db\Expression("CASE caller_ids.status 
              WHEN 0 THEN 'Deactivated' 
              WHEN 1 THEN 'Active' 
              WHEN 2 THEN 'Inactive' 
              WHEN 3 THEN 'Unregistered'
              ELSE 'Permanently Deleted' END")])
          -&gt;with('ehadata')-&gt;asArray()-&gt;all();
  
  
      return $query;
  }
  public static function findNonGeo()
  {
      $query = new CallerIdentityQuery(get_called_class());
      $query-&gt;select([
          'cidref', 'custref', 'caller_id', 'expiry', 'conf_call',
          'type', 'redirect', 'destination', 'status', 'start_date',
          'statusDesc' =&gt; new \yii\db\Expression("CASE status 
              WHEN 0 THEN 'Deactivated' 
              WHEN 1 THEN 'Active' 
              WHEN 2 THEN 'Inactive' 
              WHEN 3 THEN 'Unregistered'
              ELSE 'Permanently Deleted' END")])
          -&gt;where(['caller_ids.status' =&gt; '1'])
          -&gt;andWhere(['type' =&gt; 'N']);
      return $query;
  }
  public static function findFax()
  {
      $query = new CallerIdentityQuery(get_called_class());
  
      $query-&gt;select([
          'cidref', 'custref','caller_id', 'expiry', 'conf_call',
          'type', 'redirect', 'destination', 'status', 'start_date',
          'statusDesc' =&gt; new \yii\db\Expression("CASE status 
              WHEN 0 THEN 'Deactivated' 
              WHEN 1 THEN 'Active' 
              WHEN 2 THEN 'Inactive' 
              WHEN 3 THEN 'Unregistered'
              ELSE 'Permanently Deleted' END")])
          -&gt;where(['status' =&gt; '1'])
          -&gt;andWhere(['type' =&gt; 'F']);
      return $query;
  }
  public static function findConference()
  {
      $query = new CallerIdentityQuery(get_called_class());
  
      $query-&gt;select([
          'cidref', 'custref', 'caller_id', 'expiry', 'conf_call',
          'type', 'redirect', 'destination', 'status', 'start_date',
          'statusDesc' =&gt; new \yii\db\Expression("CASE status 
              WHEN 0 THEN 'Deactivated' 
              WHEN 1 THEN 'Active' 
              WHEN 2 THEN 'Inactive' 
              WHEN 3 THEN 'Unregistered'
              ELSE 'Permanently Deleted' END")])
          -&gt;where(['status' =&gt; '1'])
          -&gt;andWhere(['conf_call' =&gt; 'y']);
      return $query;
  }
  
  }
  </code></pre>