team1
+----------+----------+
| id1 | name |
+----------+----------+
| 1 | a |
| 2 | b |
| 3 | c |
+----------+----------+
team2
+----------+----------+
| id2 | name |
+----------+----------+
| 1 | d |
| 2 | e |
| 3 | f |
+----------+----------+
play
+----------+----------+----------+
| id3 | id1 | id2 |
+----------+----------+----------+
| 1 | 1 | 1 |
| 2 | 1 | 3 |
| 3 | 2 | 1 |
| 4 | 3 | 2 |
| 5 | 2 | 3 |
+----------+----------+----------+
I’m new to sql. I am struggling with how to set a counting condition. Let’s say for the tables above, I want to find a player from team1 who plays with a player from team2 that has played or will play at least two times total. So basically, if a value from id2 shows up more than once, then any value from id1 that plays against id2 should be part of the result. Just by looking at the table, I would want it to return id1 = 1 and id1 = 2 if it was without redundancies. I can’t wrap my head around how to go about this.
Try: