1

我试过这个:

$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);

错误信息:

SQLSTATE [42000]:语法错误或访问冲突:1055 SELECT 列表的表达式 #1 不在 GROUP BY 子句中,并且包含在功能上不依赖于 GROUP BY 子句中的列的非聚合列“affiliate_new.search_tags.name”;这与 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`

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

4

0 回答 0