title: Query with GROUP BY and ORDER BY not working when multiple columns in SELECT are chosen
body: <p>I'm updating an old website and one of the queries isn't working anymore:</p>
  
  <pre><code>SELECT * FROM tbl WHERE col1 IS NULL GROUP BY col2 ORDER BY col2
  </code></pre>
  
  <p>I noticed if I dropped the <code>GROUP BY</code> it works, but the result set doesn't match the original:</p>
  
  <pre><code>SELECT * FROM tbl WHERE col1 IS NULL ORDER BY col2
  </code></pre>
  
  <p>So I tried reading up on <code>GROUP BY</code> in the <a href="https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html" rel="nofollow noreferrer">docs</a> to see what might be the issue, and it seemed to suggest not using <code>*</code> to select all the fields, but explicitly using the column name so I tried it with just the column that was being ordered and grouped:</p>
  
  <pre><code>SELECT col2 FROM tbl WHERE col1 IS NULL GROUP BY col2 ORDER BY col2
  </code></pre>
  
  <p>Which works but after looking through the code the query requires 2 columns in the query so whoever added <code>*</code> was overdoing it, but if I add that column produces an error, similarly adding a third column produces the same error:</p>
  
  <pre><code>SELECT col2, col3 FROM tbl WHERE col1 IS NULL GROUP BY col2 ORDER BY col2
  SELECT col1, col2, col3 FROM tbl WHERE col1 IS NULL GROUP BY col2 ORDER BY col2
  </code></pre>
  
  <p>Can anyone tell me why this last query doesn't work?  I can't decipher why from the <a href="https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html" rel="nofollow noreferrer">docs</a>, but this is the minimum query required to get the result set I need.</p>
  
  <p>Running the query in Adminer I get this error</p>
  
  <pre><code>Error in query (1055): Expression #2 of SELECT list is not in GROUP BY 
  clause and contains nonaggregated column 'name.table.column' 
  which is not functionally dependent on columns in GROUP BY clause; this is 
  incompatible with sql_mode=only_full_group_by
  </code></pre>