Php MySQL被列为最多请求,限制为5

Php MySQL被列为最多请求,限制为5,php,mysql,count,Php,Mysql,Count,我有一些像这样的桌子 id | Name | useriD | bID | email 在这排我有这样的东西 1 | Michael | 34 | 45 | email@email.com 2 | Michael | 34 | 45 | email@email.com 3 | John | 34 | 45 | email@email.com 4 | John | 34 | 45 | email@email.com 5 | John | 34 | 45 | email@email

我有一些像这样的桌子

id | Name | useriD | bID | email

在这排我有这样的东西

1 | Michael | 34 | 45 | email@email.com
2 | Michael | 34 | 45 | email@email.com
3 | John    | 34 | 45 | email@email.com
4 | John    | 34 | 45 | email@email.com
5 | John    | 34 | 45 | email@email.com
6 | Jovan   | 34 | 45 | email@email.com
7 | Peter   | 34 | 45 | email@email.com
8 | Michael | 34 | 45 | email@email.com
9 | Oliver  | 34 | 45 | email@email.com
10 | Tataian | 34 | 45 | email@email.com
我需要一个查询,看看我有什么名字最多,多少次限制他们在5顶

我尝试过这样的东西,但我只得到了第一个,我需要五个名字和多少次

这就是我现在所拥有的

SELECT count(`Name`) as Requests, `Name` as Names WHERE 1

您应该能够按名称分组,按计数和限制排序:

 SELECT COUNT(`Name`) AS `Requests`, `Name` AS `Names`
 FROM `table`
 GROUP BY `Names`
 ORDER BY `Requests` DESC
 LIMIT 5
基于上表的结果如下:

   Requests   |   Names
--------------------------
      3       |     John
      3       |  Michael
      1       |    Jovan
      1       |   Oliver
      1       |    Peter

您应该能够按名称分组,按计数和限制排序:

 SELECT COUNT(`Name`) AS `Requests`, `Name` AS `Names`
 FROM `table`
 GROUP BY `Names`
 ORDER BY `Requests` DESC
 LIMIT 5
基于上表的结果如下:

   Requests   |   Names
--------------------------
      3       |     John
      3       |  Michael
      1       |    Jovan
      1       |   Oliver
      1       |    Peter