Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 本月的Sql查询,以及发送更多帖子的用户_Mysql_Sql - Fatal编程技术网

Mysql 本月的Sql查询,以及发送更多帖子的用户

Mysql 本月的Sql查询,以及发送更多帖子的用户,mysql,sql,Mysql,Sql,我试图向用户展示更多从本月开始添加到列表中的帖子。但是不起作用 SELECT *,SUM(post_id) FROM `posts` Where YEAR(date) = YEAR(NOW()) AND MONTH(date) = MONTH(NOW()) GROUP BY user_id ORDER BY id DESC LIMIT 0 , 18 sql表数据: INSERT INTO `posts` (`id`, `api_id`, `user_id`, `group_id`, `mess

我试图向用户展示更多从本月开始添加到列表中的帖子。但是不起作用

SELECT *,SUM(post_id) FROM `posts` Where YEAR(date) = YEAR(NOW()) AND MONTH(date) = MONTH(NOW()) GROUP BY user_id ORDER BY id DESC LIMIT 0 , 18
sql表数据:

INSERT INTO `posts` (`id`, `api_id`, `user_id`, `group_id`, `message`, `mentioned`, `attached`, `posttags`, `comments`, `reshares`, `date`, `date_lastedit`, `date_lastcomment`, `ip_addr`) VALUES
(1, 0, 1, 0, 'text', 0, 0, 0, 0, 0, 1360378616, 0, 1360378616, 0);

您应该在select子句中指定与group by子句中相同的列名 试试这个

SELECT user_id,SUM(post_id) FROM `posts` Where YEAR(date) = YEAR(NOW()) AND MONTH(date) = MONTH(NOW()) GROUP BY user_id ORDER BY user_id DESC LIMIT 0 , 18

在大多数SQL方言中,选择不属于分组的任何列都是非法的。(MySQL基于服务器配置允许它,但随后随机从组中的一行传递列值。)在发布问题之前阅读