1

当我使用 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有什么区别?

谢谢你。

4

2 回答 2

0

These are equivalent:

group by (b), (c)
group by b, c

Because the brackets are redundant(they have no effect), but in this:

group by (b, c)

The brackets are creating a single ordering term from the expression b, c, which is not a single value, and order by terms must be single-valued.

于 2013-10-23T08:39:07.067 回答
0

group by (b,c) 表示您按字段“b,c”分组,因为您使用“()”。

按 b,c 分组表示您按字段 b 分组,然后按字段 c 分组

于 2013-10-23T07:13:01.980 回答