I'm not even sure if their is a php or mysql function for this but maybe there is. I have a simple table. It is a match table. The two columns are like this.
id | uid1 | uid2
Basically what I want to do is figure out a user's rival. So in order to do that I simply want to be able to see who each user's rivals are. Basically whoever 1 user has faced the most is their rival. So below is an example of what a table might look like.
id | uid1 | uid2
1 | 1 | 2
2 | 3 | 1
3 | 1 | 2
If I try to find for a user id of 1 he has 3 total rows in the data. Out of that he has faced a user with the id of two twice, and the id of 3 once. So therefor his rival would be the user id 2. Is there any simple way of doing this, the only catch is there is about 5,000 entries in the table.