SELECT *, COUNT(*) AS count FROM t_search WHERE mark = 'a' GROUP BY title ORDER BY count DESC LIMIT 0, 20
SELECT *, COUNT(*) AS count FROM t_search WHERE mark = 'b' GROUP BY title ORDER BY count DESC LIMIT 0, 20
SELECT *, COUNT(*) AS count FROM t_search WHERE mark = 'c' GROUP BY title ORDER BY count DESC LIMIT 0, 20
...
一共24条SQL,mark 是 a-z 每句SQL查询20条
方法1:
mysql >= 8.0
方法2:
mysql < 8.0的