title: sql isn't in GROUP BY using query builder laravel
body: <p><a href="https://i.stack.imgur.com/OH5kj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OH5kj.jpg" alt="enter image description here"></a>
  I want to take how much amount of data based on the product_id taken from the table vote. on laravel this query does not work well but when i try it in mysql i run it fine is there any other solution? </p>
  
  <p>this is a successfully executed query through mysql :</p>
  
  <pre><code>select count(product_id) as total, `v`.*, `p`.`name` from `votes` as `v` left join `products` as `p` on `p`.`id` = (select p1.id from products as p1 where v.product_id = p1.id ) group by v.product_id
  </code></pre>
  
  <p>result :
  <a href="https://i.stack.imgur.com/HsTD9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HsTD9.jpg" alt="enter image description here"></a></p>
  
  <p>and it's a query on laravel that I use using query builder : </p>
  
  <pre><code>$count = DB::table('votes as v')-&gt;leftJoin('products as p',function($join){
    $join-&gt;on('p.id','=',DB::raw('(select p1.id from products as p1 where v.product_id = p1.id )'));
  })-&gt;select(DB::raw('count(*) as total'),'v.*','p.name')-&gt;groupBy('v.product_id')-&gt;get();
  dd($count);
  </code></pre>
  
  <p>and i got this error :</p>
  
  <blockquote>
    <p>"SQLSTATE[42000]: Syntax error or access violation: 1055
    'lookbubbledrink.v.id' isn't in GROUP BY (SQL: select count(<em>) as
    total, <code>v</code>.</em>, <code>p</code>.<code>name</code> from <code>votes</code> as <code>v</code> left join <code>products</code> as
    <code>p</code> on <code>p</code>.<code>id</code> = (select p1.id from products as p1 where v.product_id
    = p1.id ) group by <code>v</code>.<code>product_id</code></p>
  </blockquote>
  
  <p>I have to use group by product_id only to calculate how much amount of data based on the number of product_id in the vote. </p>