我有这个查询。从mysql中的多个列中选择不同的列
select Leaf_id,product_id_x,product_id_y,count from table;
我在找的是选择不同的Leaf_id的所有值。
所以我试图
select Leaf_id,product_id_x,product_id_y,count from table group by Leaf_id;
,但得到这个错误。
SELECT list is not in GROUP BY clause and contains nonaggregated column
'table.product_id_x' which is not functionally dependent on columns in
GROUP BY clause; this is incompatible with sql_mode=only_full_group_by")
我应该对所有列进行分组吗 ?
如果您注意到,启用了'sql_mode = only_full_group_by'。要根据一列进行区分,请使用SET sql_mode =''' – Viki888
添加示例表格数据和预期结果 - 以及格式化文本。 – jarlh
强烈建议'only_full_group_by'。 – jarlh