开发者

MYSQL select and limit by quantity of 'group by'

My query is as follows:

            $query = "SELECT report,";
            $query.=    "GROUP_CONCAT(DISTINCT analyst) AS analysts, ";
            $query.=    "GROUP_CONCAT(DISTINCT region) AS regions, ";
            $query.=    "GROUP_CONCAT(DISTINCT country) AS countries, ";
            $query.=    "GROUP_CONCAT(DISTINCT topic) AS topics, ";
            $query.=    "GROUP_CONCAT(DISTINCT date) AS dates, ";
            $query.=   开发者_Python百科 "GROUP_CONCAT(DISTINCT link) AS links, ";
            $query.=    "GROUP_CONCAT(DISTINCT province) AS provinces ";
            $query.=    "FROM reports GROUP BY report ORDER BY dates DESC ";  

I would like for MySQL to GROUP BY report, and also to limit that number (of reports) to 10. Any suggestions?


Simply add LIMIT 10 to the end of your query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜