What would be the fastest way to select 2 random rows from an SQL table ? (SQL only or not) I am using MySQL on PhpMyAdmin.
Asked
Active
Viewed 623 times
2 Answers
1
Seems like it would be:
SELECT * FROM table LIMIT 2
What you will get is two rows in database default order.

SamA
- 587
- 3
- 6
0
Try this:
SELECT * FROM table ORDER BY RAND() LIMIT 0, 2

Pupil
- 23,834
- 6
- 44
- 66
-
Woudln't this become noticeably slower the more tuples the table contains? – halpsb Sep 26 '13 at 17:23