3 ms·
For selecting a single random row with equal distribution and no need to worry about holes, the following might be simpler: SET @var = (SELECT FLOOR(RAND()
by jackalope 14y ago
For selecting a single random row with equal distribution and no need to worry about holes, the following might be simpler:
SET @var = (SELECT FLOOR(RAND() * COUNT(id)) from random);
PREPARE statement FROM 'SELECT name FROM random LIMIT ?, 1';
EXECUTE statement USING @var;
I don't know how well this compares in performance to the examples in the article, but it's certainly easier to comprehend.