Thanks again r937, the query was almost perfect, however it didnt only use all rows with the next larger value but the rows with all larger values. Hence I modified it with a third subquery and technically it should work fine.
Code:
SELECT *
FROM table
WHERE field=
(SELECT field
FROM table
WHERE field>
(select ROUND(RAND()*MAX(field))
from table)
ORDER BY field LIMIT 1)
ORDER BY RAND() LIMIT 1
The only problem I am encountering is that each third or fourth query returns an empty set. I am rather stumped, especially because the first subquery determining the next larger value always returns an existent value.
Code:
SELECT field
FROM table
WHERE field>
(select ROUND(RAND()*MAX(field))
from table)
ORDER BY field LIMIT 1
Am I missing something?
Bookmarks