6
I have a database where I want to pick up a random record. I can do this perfectly with:
$query = "SELECT * FROM `mytable` ORDER BY RAND()
The problem is that the database contains the entry order of the jockeys' records in the competition and no jockey 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 run the course consecutively because he would have to change horses very quickly. In fact, if it is drawn, it can only be drawn again after three other competitors. I would appreciate any ideas on how to do this.
Gustavo, this is Stackoverflow in English. Please translate your question.
– André Ribeiro
@mutlei lack the title...
– Jorge B.
@Jorgeb. Ready to go
– mutlei
Gustavo wants to do this only with SQL? or using PHP? What have you tried so far?
– Jorge B.
Why not manage this directly in the application? You can do this much more simply.
– gmsantos
Hello, after drawing what do you do? Save to a table? Which one? If not how do you know that you have already been drawn?
– Tiago Gomes