I have a database where I want to get a random record. I can do this perfectly with:
$query = "SELECT * FROM 'mytable' ORDER BY RAND()
The problem is that the database contains the order of entry of the records of the jockeys in the competition and no jock can run the course consecutively. I have the following table:
+----------------+---------+-----+
| jumper | horse | id |
+----------------+---------+------
| Pedro | gfs | 1 |
| Gustavo | psg | 2 |
| Breno | sdwed | 3 |
| bruno | sdsd | 4 |
| Carlos | powkd | 5 |
| Andrea | linda | 6 |
| Gustavo | handara | 7 |
+----------------+---------+-----+
I have to prevent the jockey Gustavo from being drawn to the course consecutively because he would have to change horses very quickly. In fact, if it is raffled, it can only be raffled again after three other competitors. I would appreciate any ideas on how to do this.