I have a Mysql database table with ~10000 songs. One column is the last time they've been played. I want to randomly select a song, giving more weight to the least played songs. It should be a fast query, so maybe we don't need to count the number of times a song's been played and just use the 'last_play' column to calculate the weight.
I'm using PHP and Mysql and I'm not sure if I can do the query with just SQL or if I need to get all 10.000 results and then make calculations using PHP.
Could you please help me with the query? Maybe there is a better approach to solve the problem?
Aucun commentaire:
Enregistrer un commentaire