You can try to do this in the php loop, but I doubt it will be faster ..
$iMaxID = getMaxIdFromYourTable();
$records = array();
while (true) {
$iRandID = rand(1,$iMaxID);
thisRecord = "SELECT FROM yourtable WHERE id = $iRandID";
if (numrows > 0) {
$records[] = thisRecord;
if (count($records) > 50) {
break;
}
}
}
source
share