I am running MySQL 3.23.54. Query: SELECT column1, column2, RAND() AS column3 FROM table WHERE column2 IS NOT NULL ORDER BY column3 LIMIT 10;
I am running this query within a PHP page that uses mysql_connect. More then 9 out of 10 times I get the first 10 rows of the database in order, i.e. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. Every once in a while, I get it in a different order, however, very rarely. This exact PHP file works on another server which is running an earlier version of MySQL (3.23.41). Moved to this server, I can't seem to pull 10 random rows from the database. I've tried initializing RAND with a number but that didn't help. I'd consider just generating the random numbers myself and selecting the rows, however, I need the WHERE column2 IS NOT NULL as part of the query so it needs to be randomized within MySQL. I've altered the program to echo column3 (the random number) and I get a different set of numbers each time so it isn't a cached result or anything like that. The numbers are simply coming out in the same order as the rows are originally in the database on most attempts. I tried the query from command line (MySQL client) and the results seem to be more randomized then when called via PHP, however, I'm having a hard time finding any clues on either end (MySQL or PHP) as to why I'm not getting random results. This query works on my other servers (which are running earlier versions of MySQL). Any thoughts or help is appreciated. Scott -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]