gpt4 book ai didi

mysql - group by() 和 group by 的区别

转载 作者:行者123 更新时间:2023-11-30 23:11:37 32 4
gpt4 key购买 nike

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

谢谢。

最佳答案

这些是等价的:

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

因为括号是多余的(它们没有作用),但是在这个:

group by (b, c)

方括号从表达式 b, c 创建单个排序项,它不是单个值,order by 项必须是单值的。

关于mysql - group by() 和 group by 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19534737/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com