Answer the question
In order to leave comments, you need to log in
Why does it give an error when querying the database?
$items = DB::table('catalog_index AS f')
->select(DB::raw("
cp.name,
cp.type,
f.facet_id,
f.value,
MIN(f.value_num) min_value_num,
MAX(f.value_num) max_value_num,
COUNT(DISTINCT f.product_id) AS cnt
"))
->join('catalog_properties AS cp', 'cp.id', '=', 'f.facet_id')
->where('f.section_id', '=', 440)
->groupBy(['f.facet_id', 'f.value'])
->get();
SQLSTATE[42000]: Syntax error or access violation: 1055 'test-db.cp.name' isn't in GROUP BY (SQL: select cp.name, cp.type, f.facet_id, f.value, MIN(f .value_num) min_value_num, MAX(f.value_num) max_value_num, COUNT(DISTINCT f.product_id) AS cnt from `catalog_index` as `f` inner join `catalog_properties` as `cp` on `cp`.`id` = `f `.`facet_id` where `f`.`section_id` = 440 group by `f`.`facet_id`, `f`.`value`)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question