2006-02-22, 16:40
i was thinking about this morning on my way into work. i've got a nice easy way to do it:
1) get the number of matching songs with "select count(*) from songview" (later add "where ...")
2) pick random number (irandom) based on the number of matching songs.
3) get random song with "select * from songview orderby songview.idsong offset irandom limit 1" and this too can later have the same where clause.
as for the history, the where clause can include something like
"where not idsong in (list)" to account for the history.
1) get the number of matching songs with "select count(*) from songview" (later add "where ...")
2) pick random number (irandom) based on the number of matching songs.
3) get random song with "select * from songview orderby songview.idsong offset irandom limit 1" and this too can later have the same where clause.
as for the history, the where clause can include something like
"where not idsong in (list)" to account for the history.