开发者

MYSQL select and limit by quantity of 'group by'

开发者 https://www.devze.com 2023-03-05 11:11 出处:网络
My query is as follows: $query = \"SELECT report,\"; $query.=\"GROUP_CONCAT(DISTINCT analyst) AS analysts, \";

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

精彩评论

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