Re: [PHP] Random Row From Database
On Sunday 11 November 2001 05:18, HEW Staff wrote: Hi, I'm trying to pull a random row from my database and display the contents. I know that the code: SELECT * FROM TABLENAME WHERE RAND() LIMIT 1 should work. (1) [EMAIL PROTECTED] has nothing to do with this. So don't crosspost to there. (2) No, it shouldn't work WHERE RAND () means where some random number evaluates to true (i.e. is nonzero) you want ORDER BY RAND () LIMIT 1 -- Christian Reiniger LGDC Webmaster (http://lgdc.sunsite.dk/) ...1000100011010101101010110100111010113... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Random Row From Database
Hi, I'm trying to pull a random row from my database and display the contents. I know that the code: SELECT * FROM TABLENAME WHERE RAND() LIMIT 1 should work. However, there are 19 rows in the database and only the first row ever shows up. Is there a way to do this to ensure uniqueness? The code I am using at the moment also filters so that rows are pulled from the database given certain other criteria such as: SELECT * FROM TABLENAME WHERE PayerID=$id AND RAND() LIMIT 1 All of the rows in the database contain the same PayerID and this column is not the Primary Key. Any help much appreciated. Jonathan S Hardiman President/CEO Hardiman Enterprises Worldwide -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]