I am using this database: http://www.4redpixels.com/uploads/words.sql
I want to select a random word starting with a X (unknown) letter. How can I do that?
Actually, the best way to get words that start with a particular letter is to use like
:
select w.word
from words w
where w.word like 'x%'
order by rand()
limit 1;
This can take advantage of an index on words(word)
. In addition, if the list is really long, there are better ways to get a random row than just order by rand()
.