Sie können es mit einer Abfrage wie folgt tun:
SELECT t.team_id ,o.opponents_id FROM yourTAble t
INNER JOIN (
SELECT team_id,opponents_id FROM yourTAble
GROUP BY opponents_id
HAVING count(*) = 1
) AS o ON o.team_id = t.team_id
GROUP BY t.team_id
HAVING count(*) = 1;
Probe
mysql> select * from yourTable;
+---------+--------------+
| team_id | opponents_id |
+---------+--------------+
| 1 | 5 |
| 1 | 6 |
| 2 | 7 |
| 2 | 80 |
| 3 | 9 |
| 4 | 11 |
| 4 | 22 |
| 8 | 5 |
+---------+--------------+
8 rows in set (0,00 sec)
mysql> SELECT t.team_id ,o.opponents_id FROM yourTAble t
-> INNER JOIN (
-> SELECT team_id,opponents_id FROM yourTAble
-> GROUP BY opponents_id
-> HAVING count(*) = 1
-> ) AS o ON o.team_id = t.team_id
-> GROUP BY t.team_id
-> HAVING count(*) = 1;
+---------+--------------+
| team_id | opponents_id |
+---------+--------------+
| 3 | 9 |
+---------+--------------+
1 row in set (0,00 sec)
mysql>
siehe Kommentar
mysql> SELECT count(*) AS cnt , team_id
-> FROM keezdrives_played
-> GROUP BY team_id
-> ;
+-----+---------+
| cnt | team_id |
+-----+---------+
| 4 | 2281 |
| 4 | 2282 |
| 4 | 2283 |
| 4 | 2284 |
| 4 | 2285 |
| 4 | 2286 |
+-----+---------+
6 rows in set (0,00 sec)
mysql>
man versuchen, mehr
SELECT team_id,opponents_id
FROM keezdrives_played
GROUP BY CONCAT(team_id, '-', opponents_id)
HAVING count(*) = 1;
versuchen letzten
SELECT * FROM (
SELECT t.team_id ,t.opponents_id
FROM keezdrives_played t
GROUP BY t.team_id
) r
GROUP BY r.opponents_id;
Verwendung distinct (oppnents_id) wollen –