How to select random records from MySQL table?

Total Post:68

Points:476

MYSQL 
 2853  View(s)
Ratings:
Rate this:
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.
  1. Re: How to select random records from MySQL table?

    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.

      Modified On Mar-12-2012 01:36:42 AM

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.