title: SQL_MODE not working on MySQL 5.7.18
body: <p>I'm getting the following error from my PHP application:</p>
  
  <blockquote>
    <p>Incorrect SQL query (Database) In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'db_20172201.cm_order.buyer'; this is incompatible with sql_mode=only_full_group_by</p>
  </blockquote>
  
  <p>After looking around for a while, and after trying to identify the query that gave this error I decided that I should change the SQL_MODE option in my MySQL server.</p>
  
  <p>I did 2 things to accomplish this:</p>
  
  <ul>
  <li><p>executed this query </p>
  
  <pre><code>SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
  </code></pre></li>
  <li><p>Added the following in <code>my.cnf</code> which is the configuration file for MySQL </p>
  
  <pre><code>[mysqld]
  sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
  </code></pre></li>
  </ul>
  
  <p>I thought that these to would be enough but the error never goes away from my application.
  When I check for the value of <code>SQL_MODE</code> in my environment by this query</p>
  
  <pre><code>SELECT @@GLOBAL.sql_mode
  </code></pre>
  
  <p>it shows the values inserted above.</p>
  
  <p>I don't know where else to look. I also tried to set the sql_mode variable from my application before executing a query but doesn't solve.</p>
  
  <p>--- UPDATE</p>
  
  <p>I just printed in my application the result of the query <code>SELECT @@SESSION.SQL_MODE</code> and it turns out to be as I set it:</p>
  
  <pre><code>array(1) { [0]=&gt; object(stdClass)#5 (1) 
      { 
          ["@@SESSION.sql_mode"] =&gt; string(118) "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
      }
  }
  </code></pre>
  
  <p>But I still get the error</p>
  
  <p>PS. MySQL version is 5.7.18</p>