title: How to resolve "ORDER BY clause is not in SELECT list" caused MySQL 5.7 with SELECT DISTINCT and ORDER BY
body: <p>I installed the new Ubuntu and my code has got a problem with MySQL.</p>
  
  <pre class="lang-none prettyprint-override"><code>( ! ) Warning: PDOStatement::execute(): SQLSTATE[HY000]: General error: 3065 
  Expression #2 of ORDER BY clause is not in SELECT list, references column 'clicshopping_test_ui.p.products_date_added' which is not in SELECT list; this is incompatible with DISTINCT 
  in /home/www//boutique/includes/OM/DbStatement.php on line 97s
  </code></pre>
  
  <p>It seems MySQL 5.7 does'nt allow a request like:</p>
  
  <pre><code>select .... distinct with  order by rand(), p.products_date_added DESC
  </code></pre>
  
  <p>If I use this it works: </p>
  
  <pre><code>select distinct .... with  order by rand(), 
  </code></pre>
  
  <p>How to resolve this situation ?</p>
  
  <p>My SQL request in PHP</p>
  
  <pre><code> $Qproduct = $OSCOM_PDO-&gt;prepare('select distinct p.products_id,
              p.products_price
              from :table_products p left join :table_specials s on p.products_id = s.products_id
              where products_status = :products_status
              and products_view = :products_view
              and p.products_archive = :products_archive
              order by rand(),
              p.products_date_added DESC
              limit :products_limit');
                    $Qproduct-&gt;bindInt(':products_status', 1);
                    $Qproduct-&gt;bindInt(':products_view', 1);
                    $Qproduct-&gt;bindInt(':products_archive', 0);
                    $Qproduct-&gt;bindInt(':products_limit', 
                    (int)MODULE_FRONT_PAGE_NEW_PRODUCTS_MAX_DISPLAY);
  </code></pre>