I'm a newbie to MySQLi and have searched the internet for almost two weeks but cannot find any best result.
Is there any good way to select random records from database using mysqli better than ORDER BY RAND() function?
I heard this function takes times to process just to pick out five from a million records in the database.
Or else, should I use a traditional MySQL way instead of this.
Thanks in advance
Have a read of [this thread where different methods are discussed. The method I personally prefer is to run the select query without the use of a limit to get all records that can be chosen from then once the result set is in an array. Then I would use [URL="http://php.net/manual/en/function.array-rand.php"]array_rand()](http://www.sitepoint.com/forums/mysql-182/speedy-order-rand-operation-727493.html) on the result set to grab x random rows.
array_rand() is a PHP function but hopefully whatever language your using will have an equivalent function.
Thanks for pointed out. I read it now.
Hello there again SpacePhoenix,
I've tested your code. It's perfect for me.