toby wrote:
> Oops, I see, you said 4.1.16. According to 4.1 manual, the above should
> work, returning one row every time. The manual also explains why WHERE
> RAND() fails:
> http://dev.mysql.com/doc/refman/4.1/...html#id2978318
I had seen that--my mistake was in misunderstanding how often the
"where" clause is reevaluated. I assumed it was evaluated once per
search, not once per row.
> > For speed, have you tried:
> >
> > SELECT COUNT(*) FROM nouns INTO @cnt; -- or keep external count
> > SELECT FLOOR(RAND()*@cnt) INTO @id; -- or generate externally
> > SELECT word FROM nouns WHERE id=@id;
I've decided to produce the random indexes externally--that seems like
the fastest method and is easier than the multiple select statements
necessary to get MySQL to do it for me.
Thanks,
Walter