PGError:错误:列“inboxes.id”必须出现在 GROUP BY 子句中或在聚合函数中使用
我对 MySQL 数据库有以下查询:
SELECT inboxes.*
, count(inboxes.conv) AS times
, max(created_at) AS created_at
FROM `inboxes`
WHERE to_user = 2
OR account_id = 2
GROUP BY conv
ORDER BY id DESC
此查询在我的本地主机上运行,但如果我将其部署到 Heroku,我会收到此错误:
PGError: ERROR: column "inboxes.id" must appear in the GROUP BY clause or
be used in an aggregate function
I have the following query to MySQL database:
SELECT inboxes.*
, count(inboxes.conv) AS times
, max(created_at) AS created_at
FROM `inboxes`
WHERE to_user = 2
OR account_id = 2
GROUP BY conv
ORDER BY id DESC
This query works on my localhost, but if I deploy it to Heroku, I'll get this error:
PGError: ERROR: column "inboxes.id" must appear in the GROUP BY clause or
be used in an aggregate function
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(3)
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您应该删除
收件箱。*
。列出您需要获取的每个参数。所有参数必须进行分组(
GROUP BY
)或与分组函数(MAX
等)一起使用。我无法告诉你为什么它在你的本地主机上工作。
You should get rid of the
inboxes.*
. List each single parameter you need to fetch.All parameters must be either grouped (
GROUP BY
) or used together with a group function(MAX
, etc.).I cannot tell you why its working on your localhost.