0

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.

Taryn
  • 242,637
  • 56
  • 362
  • 405
halpsb
  • 1,106
  • 2
  • 18
  • 28

2 Answers2

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