当我使用mysql时,我得到了这个错误,请任何人给我解释一下。下面的A,B,C之间有什么不同?
A) select * from table where a=a group by(b) // this execute & work fine
B) select * from table where a=a group by b,c // this execute * work fine
c) select * from table where a=a group by (b,c) // this is giving an error - error is operand should contain 1 column.在A中,它工作得很好,没有括号的错误,但当我在C中使用相同的方法进行多个分组时,它不起作用,并给出了提到的错误。
为什么会这样呢?在mysql分组中,group by ()和group by有什么区别?
谢谢你。
发布于 2013-10-23 15:13:02
group by (b,c)表示按字段"b,c“分组,因为您使用"()”。
按b分组,c表示先按字段b分组,再按字段c分组
发布于 2013-10-23 16:39:07
这些是等效的:
group by (b), (c)
group by b, c因为括号是多余的(它们没有效果),但在下面的代码中:
group by (b, c)括号从表达式b, c创建单个排序项,它不是单个值,并且order by项必须是单值的。
https://stackoverflow.com/questions/19534737
复制相似问题