Possible Duplicate:
Selecting Random Rows in MySQL
I'm creating a simple web application using PHP and MySQL. In it, I need to randomly select a small set of rows from a table in a random order. How can I achieve such thing using MySQL?
Possible Duplicate:
Selecting Random Rows in MySQL
I'm creating a simple web application using PHP and MySQL. In it, I need to randomly select a small set of rows from a table in a random order. How can I achieve such thing using MySQL?
SELECT * FROM table ORDER BY RAND() LIMIT 10;
Edit:
Useful information about the MySQL RAND() function can be found here.
select * from table order by rand() limit 10
Note that order by rand()
with large dataset is very slow but in your case it's not a problem.
you could do that using RAND() function .
SELECT questine FROM tablename ORDER BY RAND() LIMIT 10
will select 10 questines at random under assumption the questine is stored under field questine