1

I tried this:

$searchValues = explode(' ', $this->search);
$searchTermKeywords = array();

foreach ($searchValues as $word) {
    $searchTermKeywords[] = " search_tags.name LIKE '%$word%'";
}

$results[0] = DB::table('search_tags')
        ->select('search_tags.name', 'product.*')
        ->join('product', 'search_tags.product_id','product.id')
        ->whereRaw(implode(' OR ', $searchTermKeywords))
        ->where([['product_quantity', '>', 0], ['active_status', '=' ,1]])
        ->groupBy('search_tags.product_id')
        ->paginate(10);

Error message:

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'affiliate_new.search_tags.name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL:

select count(*) as aggregate 
from (select `search_tags`.`name`, `product`.* 
     from `search_tags` 
     inner join `product` on `search_tags`.`product_id` = `product`.`id` 
     where search_tags.name LIKE '%pen%' 
        OR search_tags.name LIKE '%drive%' 
       and (`product_quantity` > 0 and `active_status` = 1) 
     group by `search_tags`.`product_id`) as `aggregate_table`

) (View: C:\Users...\Desktop\my_project\resources\views\result.blade.php)

Akina
  • 39,301
  • 5
  • 14
  • 25
Chinthaka
  • 11
  • 5
  • 2
    Does this answer your question? [SELECT list is not in GROUP BY clause and contains nonaggregated column .... incompatible with sql\_mode=only\_full\_group\_by](https://stackoverflow.com/questions/41887460/select-list-is-not-in-group-by-clause-and-contains-nonaggregated-column-inc) – Gert B. Aug 05 '21 at 09:18
  • 1
    Remove `product.*` selection in the subquery. – Akina Aug 05 '21 at 09:20

0 Answers0