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
  • 234,956
  • 54
  • 359
  • 399
halpsb
  • 1,010
  • 2
  • 18
  • 27

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,528
  • 5
  • 42
  • 64