简体   繁体   中英

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.=    "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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM