B boomers Established Member โ 20 โ Impact 4 Feb 17, 2006 664 views 4 replies #1 Is there a way to select a random record from within an SQL database?
A AllValley Established Member โ 15 โ Impact 1 Feb 17, 2006 #2 Might try looking at the mysql.org website. I cant think of one off hand though. You could create a php/js script that generated random numbers, and have it feed those into a variable for calling record numbers....
Might try looking at the mysql.org website. I cant think of one off hand though. You could create a php/js script that generated random numbers, and have it feed those into a variable for calling record numbers....
Kate Domainosaurus RexTop Member VIP โ 20 โ Impact 21,831 Feb 17, 2006 #3 Have a look here: http://www.namepros.com/programming...-quote-database-php.html?highlight=order+rand
Have a look here: http://www.namepros.com/programming...-quote-database-php.html?highlight=order+rand
B Barts Established Member โ 15 โ Impact 10 Feb 17, 2006 #4 Which DBMS? If you're talking about MS SQL, do a order by newid() trick "select * from sometable order by newid()" If you're talking abouit MySQL use rand: "select * from sometable order by rand()"
Which DBMS? If you're talking about MS SQL, do a order by newid() trick "select * from sometable order by newid()" If you're talking abouit MySQL use rand: "select * from sometable order by rand()"
Tree Established Member โ 15 โ Impact 9 Feb 18, 2006 #5 If you're looking to select just one record do this query Code: select * from table where some_key = rand()
If you're looking to select just one record do this query Code: select * from table where some_key = rand()