Re: random order by id

From: Date: Sat, 18 May 2002 21:46:24 +0000
Subject: Re: random order by id
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98295@lists.php.net to get a copy of this message
If you are using MySQL try looking at this page for the function rand(): http://www.mysql.com/doc/M/a/Mathematical_functions.html Here's a little overview of what it says: "In MySQL Version 3.23, you can, however, do: SELECT * FROM table_name ORDER BY RAND() This is useful to get a random sample of a set SELECT * FROM table1,table2 WHERE a=b AND c<d ORDER BY RAND() LIMIT 1000. Note that a RAND() in a WHERE clause will be re-evaluated every time the WHERE is executed. RAND() is not meant to be a perfect random generator, but instead a fast way to generate ad hoc random numbers that will be portable between platforms for the same MySQL version. " Cheers! Rick Nobody will ever win the Battle of the Sexes. There's just too much fraternizing with the enemy. - Henry Kissinger > From: Jule <jslootbeek@clarku.edu> > Date: Sat, 18 May 2002 17:41:59 -0400 > To: php-general@lists.php.net > Subject: [PHP] random order by id > > > Hey guys, > i have a db and a table with id and questions > now i want these questions to be listed in a random order, is there a way > to format my SQL query or do i need some PHP work to? > i can ofcourse select a random one, that's no problem, but how do i make > sure that that one does not get chosen again. and that after it has printed > all the records it stops > any ideas? > > Jule > > -- > |\/\__________________________/\/| > | Jule Slootbeek | > | jslootbeek@clarku.edu | > | http://blindtheory.cjb.net | > | __________________________ | > |/\/ \/\| > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#98295) next »