Mysql:聚合功能在没有 group by 的情况下不起作用 [英] Mysql : Aggregation function is not working without group by

查看:41
本文介绍了Mysql:聚合功能在没有 group by 的情况下不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下查询

SELECT count(*) as num,id,page_name FROM project_page where p_id = '256'

此查询在 mysql 版本 5.1.49-3 上运行良好,并在 mysql 5.0.32-Debian_7etch8-log 上出错在两台服务器上,我有完全相同的数据库.

this query is running fine on mysql version 5.1.49-3 and giving error on mysql 5.0.32-Debian_7etch8-log On both server i have exactly same database.

错误信息

#1140 - 如果没有 GROUP BY 子句,将 GROUP 列 (MIN(),MAX(),COUNT(),...) 与没有 GROUP 列的混合是非法的

如何在 5.0.31 上运行上述查询而没有任何错误

How do i run the above query on 5.0.31 without any error

请帮忙.

推荐答案

添加... GROUP BY num, id, page_name

这篇关于Mysql:聚合功能在没有 group by 的情况下不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆