Hi,
i'm using this statement "select * from mytable order by rand() limit 1"
but it returns the same record everytime
anyone got any idea?
hi,
I'd say that ORDER BY can only be followed by ASC or DESC...
ORDER BY column [ ASC| DESC][ , column2 [ ASC| DESC] ,...]
this is the solution :o
On some platforms with some versions of MySQL RAND() is broken, try running the query twice, sometimes that fixes it. mysql_query ("SELECT * FROM whatever ORDER BY RAND()"); Then do it again and use the second result: $result = mysql_query ("SELECT * FROM whatever ORDER BY RAND()"); $array = mysql_fetch_array ($result); print_r ($array);
On some platforms with some versions of MySQL RAND() is broken, try running the query twice, sometimes that fixes it.
mysql_query ("SELECT * FROM whatever ORDER BY RAND()");
Then do it again and use the second result:
$result = mysql_query ("SELECT * FROM whatever ORDER BY RAND()"); $array = mysql_fetch_array ($result);
print_r ($array);