I know about the RAND() function in SQL to select random rows from a table, but the problem is I don’t want it selecting different random rows each time I refresh the browser. I want the same set of random rows, which is selected based on a key.
For example, say this is my table:
----------------------
| id | word | literal|
----------------------
| 1 | say | YAS |
----------------------
| 2 | eat | TAE |
----------------------
| 3 | hit | TIH |
----------------------
| 4 | bad | DAB |
----------------------
| 5 |delve | EVLED |
----------------------
maybe if the key was 6, it would select rows 4 & 5 every time. But maybe if the key was 3, it would select rows 2 and 5. So it would select a set of random rows each time based on a key.
Is this possible?
You can use the : Rand(N) form of the MySQL function and take care to pass the same N each time you want the same sequence of generated random numbers. The N could stay the same during a specific session or it could be stored in a cookie for use over a longer period. It depends on how long you need the sequence to remain the same.