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.
Hi Arun Singh, To 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.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
To 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.