MYSQL选择和限制'group by'的数量

时间:2011-05-11 22:01:09

标签: php mysql limit

我的查询如下:

            $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.=    "GROUP_CONCAT(DISTINCT link) AS links, ";
            $query.=    "GROUP_CONCAT(DISTINCT province) AS provinces ";
            $query.=    "FROM reports GROUP BY report ORDER BY dates DESC ";  

我想要MySQL到GROUP BY报告,并且还要将(报告的)数量限制为10.任何建议?

1 个答案:

答案 0 :(得分:2)

只需将LIMIT 10添加到查询的末尾即可。