Forum Moderators: open

Message Too Old, No Replies

mysql return random row problem

         

topr8

4:09 pm on Feb 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



using the following query to return a random row

SELECT a,b,c FROM table ORDER BY RAND() LIMIT 1;

i assumed it would work, there are only 4 rows in the table, it nearly always returns a particular row, but occasionally returns one of the others.

the point is to return a banner to display randomly.

is there an error in the sql
or
is the table too small
or
any better suggestions

topr8

4:34 pm on Feb 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



ok, after much headbanging turns out its a bug in mysql previous to 3.23.56

for those that seek the solution - just run the query twice before breaking the connection