title: $wpdb->get_results query returns different (wrong) results compared to phpmyadmin
body: <p>I have 4 custom tables in my database - <code>wp_api_teams</code>, <code>wp_api_matches</code>, <code>wp_api_competitions</code> and <code>wp_api_federations</code>. They are part of my Wordpress database, this is how they look (I'm using foreign keys and all of that):</p>
  
  <p><a href="https://i.stack.imgur.com/xJMoz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xJMoz.png" alt="phpmyadmin schema"></a></p>
  
  <p>I am trying to output all the teams that are part of a federation. When I run this in phpmyadmin it works:</p>
  
  <pre><code>SELECT
      wp_api_teams.team_id,
      wp_api_teams.title,
      wp_api_competitions.comp_id,
      wp_api_competitions.title,
      wp_api_federations.federation_id,
      wp_api_federations.title
  FROM
      wp_api_teams
  JOIN wp_api_matches
      ON wp_api_teams.team_id = wp_api_matches.hometeam_id OR wp_api_teams.team_id = wp_api_matches.awayteam_id
  JOIN wp_api_competitions
      ON wp_api_matches.comp_id = wp_api_competitions.comp_id
  JOIN wp_api_federations
      ON wp_api_competitions.federation_id = wp_api_federations.federation_id
  WHERE wp_api_federations.federation_id = 1
  GROUP BY (wp_api_teams.team_id);
  </code></pre>
  
  <p>I get the exact results that I am looking for.</p>
  
  <pre><code>-----------------------------------------------------------------------------------
  | team_id | title              | comp_id | title          | federation_id | title |
    1         Arsenal              1         Premier League   1               England
    2         Chelsea              1         Premier League   1               England
    3         Liverpool            1         Premier League   1               England
    4         Manchester United    1         Premier League   1               England
    5         Manchester City      1         Premier League   1               England
  </code></pre>
  
  <p>This is the code I'm using in Wordpress:</p>
  
  <pre><code>global $wpdb;
  $sql = "
  SELECT
      wp_api_teams.team_id,
      wp_api_teams.title,
      wp_api_competitions.comp_id,
      wp_api_competitions.title,
      wp_api_federations.federation_id,
      wp_api_federations.title
  FROM
      wp_api_teams
  JOIN wp_api_matches
      ON wp_api_teams.team_id = wp_api_matches.hometeam_id OR wp_api_teams.team_id = wp_api_matches.awayteam_id
  JOIN wp_api_competitions
      ON wp_api_matches.comp_id = wp_api_competitions.comp_id
  JOIN wp_api_federations
      ON wp_api_competitions.federation_id = wp_api_federations.federation_id
  WHERE wp_api_federations.federation_id = 1
  GROUP BY wp_api_teams.team_id
  ";
  $test = $wpdb-&gt;get_results($sql);
  echo('&lt;pre&gt;');
  print_r($test);
  echo('&lt;/pre&gt;');
  </code></pre>
  
  <p>and the result that I'm getting is missing two table columns:</p>
  
  <pre><code>Array
  (
      [0] =&gt; stdClass Object
          (
              [team_id] =&gt; 1
              [title] =&gt; England
              [comp_id] =&gt; 1
              [federation_id] =&gt; 1
          )
      [1] =&gt; stdClass Object
          (
              [team_id] =&gt; 2
              [title] =&gt; England
              [comp_id] =&gt; 1
              [federation_id] =&gt; 1
          )
  </code></pre>
  
  <p>.... and so on.</p>
  
  <p>As you can see, the <code>wp_api_teams.title</code> and <code>wp_api_competitions.title</code> columns are missing from the result.</p>
  
  <p>So my questions is, why is this happening, why are these columns being omitted and is there anything I can do to fix this, because I absolutely need them in my returned result. How can the same query produce a different result in WP vs PHPmyadmin.</p>
  
  <p>Is this a known bug or is there something wrong with my code?</p>
  
  <p>I'm running <code>10.2.14-MariaDB</code> on <code>localhost</code> and all the table engines are <code>InnoDB</code>.</p>