最常见的价值

cra*_*ame 1 mysql

我有一张桌子上有一些书.这些是领域:

----------------------------------------------------
| book             | genre    | author             |
----------------------------------------------------
----------------------------------------------------
| The DaVinci code | thriller | Dan Brown          |
----------------------------------------------------
| Odd Thomas       | horror   | Dean Kunz          |
----------------------------------------------------
| Fairy Tales      | child    | The Grimm brothers |
----------------------------------------------------
| Inferno          | thriller | Dan Brown          |
----------------------------------------------------
| Digital Fortres  | sci-fi   | Dan Brown          |
----------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

我想让"丹·布朗"成为表中大多数书籍的作者.你能帮我怎么样?谢谢

Adr*_*nBR 5

select author -- what you select
from table -- from where
group by author -- grouping on author so you can get count of entries for each author
order by count(*) desc -- order by the number of entries descending
limit 1 -- keep first row only
Run Code Online (Sandbox Code Playgroud)