可以查詢某個字段在數據庫中出現最多的前N項
SELECT TOP N author,ct=count(author) FROM YourTableName GROUP BY author ORDER BY ct DESC
但是在MYSQL5.0以後,好像不能用,改成這樣就能用了
SELECT author,count(author) as ct FROM YourTableName GROUP BY author ORDER BY ct DESC LIMIT N
分类: MySQL 评论(58) 浏览(48031)
可以查詢某個字段在數據庫中出現最多的前N項
SELECT TOP N author,ct=count(author) FROM YourTableName GROUP BY author ORDER BY ct DESC
但是在MYSQL5.0以後,好像不能用,改成這樣就能用了
SELECT author,count(author) as ct FROM YourTableName GROUP BY author ORDER BY ct DESC LIMIT N
留下你的看法: