I didn't find how Lars has done it, but anyway I have something similar on my site: to pull a song at random from a database table (using PostgreSQL) the query is
select id, artist, album, title, artist_url, album_url
from SONGS
order by random()
limit 1 offset 0
The key is the
order by random()
to achieve the random ordering and the
limit 1 offset 0
clause to get only the first row of the results.
Of course if there are better ways to do it I would be happy to know.