jeudi 18 juin 2015

Getting RAND() from MySQL... excluding last RAND()

I have a very small table (~10) and I want to get a single different row on every SELECT query. I am using RAND() but with only 10 or so records, the probability for RAND() to reselect the same row is very high. How can I ensure that the next RAND() is different than the last?

I am using PHP, and I can easily create a crude while loop that does another SELECT if the results are same as the last, but is there a more preferred MySQL only way to do this? I can pass back the last selected row ID if that helps...




Aucun commentaire:

Enregistrer un commentaire