Revision: 44925
Updated Code
at April 20, 2011 23:16 by aamirrajpoot
Updated Code
//This is pseudo code for fetching 1 random row. I will update to add a new solution to fetch more random rows. function randomRow(table, Idcolumn) { maxRow = query("SELECT MAX(Idcolumn) AS maxID FROM table"); if (maxRow.recordCount > 0) { do { randomID = randRange(1, maxRow.maxID); randomRow = query("SELECT * FROM table WHERE column = randomID"); } while (randomRow.recordCount == 0); return randomRow; } else { return false; } }
Revision: 44924
Updated Code
at April 20, 2011 23:07 by aamirrajpoot
Updated Code
function randomRow(table, Idcolumn) { maxRow = query("SELECT MAX(Idcolumn) AS maxID FROM table"); if (maxRow.recordCount > 0) { do { randomID = randRange(1, maxRow.maxID); randomRow = query("SELECT * FROM table WHERE column = randomID"); } while (randomRow.recordCount == 0); return randomRow; } else { return false; } }
Revision: 44923
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 20, 2011 23:01 by aamirrajpoot
Initial Code
function randomRow(table, Idcolumn) { var maxRow = query("SELECT MAX(Idcolumn) AS maxID FROM table"); do { randomID = randRange(1, maxRow.maxID); randomRow = query("SELECT * FROM table WHERE column = randomID"); } while (randomRow.recordCount == 0); return randomRow; }
Initial URL
Initial Description
Another version for my old Order by Rand function now it includes some PHP
Initial Title
Order by rand() Reduce time II
Initial Tags
mysql
Initial Language
PHP