為什嗎老師的group by后面只有goods_name,但卻可以投影出good_id,求大佬解答。
我的代碼:
mysql> select goods_id,goods_name from tdb_goods group by goods_name;
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'scoredb.tdb_goods.goods_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
2020-08-10
可以參考一下:https://www.cnblogs.com/chancy/p/10026097.html
2020-04-01
就是想讓查詢結果顯示goods_id和goods_name兩個嘛,用到GROUP BY只是想讓查詢結果按照goods_id來分組顯示,不可能同時在GROUP BY后面同時按照兩個來分組,這是實現不了的