我想为字母表中的每个字母创建一个包含几个结果的索引页面。
目前我有这个:
SELECT url_slug, name FROM artists WHERE name LIKE "A%" ORDER BY rand() LIMIT 10
SELECT url_slug, name FROM artists WHERE name LIKE "B%" ORDER BY rand() LIMIT 10
SELECT url_slug, name FROM artists WHERE name LIKE "C%" ORDER BY rand() LIMIT 10
SELECT url_slug, name FROM artists WHERE name LIKE "D%" ORDER BY rand() LIMIT 10
SELECT url_slug, name FROM artists WHERE name LIKE "E%" ORDER BY rand() LIMIT 10
SELECT url_slug, name FROM artists WHERE name LIKE "F%" ORDER BY rand() LIMIT 10
是否有另一种性能更友好的方法来实现这一目标?
Ps 我知道'order by rand()' 不是很好。但这只是在开发中。