Hello Everyone,
I'm facing a problem since last night, actually I want to select records from MySQL table randomly. So please tell me whether any option in MySQL database to perform this action.
Please reply as soon as possible.
How to select random records from MySQL table?
340910-Mar-2012
Pravesh Singh
12-Mar-2012To select record from MySQLdatabase randomly, you can use ORDER BY RAND() function. This function returns table values randomly. You can use this as follows.
Query: SELECT * FROM `table` ORDER BY RAND() ;
You can also use this query to perform this action.
Query: SELECT * FROM `table` ORDER BY RAND() LIMIT 2;
where limit is used for random id limit.
I hope this solution might be helpful for you.