SELECT p1.*, p2.*
FROM player p1
JOIN team t1
ON t1.id = p1.team_id AND t1.id = My_Team_ID
LEFT JOIN player p2
ON p2.id != p1.id
JOIN team t2
ON t2.id = p2.team_id AND t2.id != My_Team_ID
LEFT JOIN game g1
ON (g1.playerA_id = p1.id OR g1.playerB_id = p1.id)
AND (g1.playerA_id = p2.id OR g1.playerB_id = p2.id)
WHERE g1.id IS NULL
यदि मैं My_Team_ID के लिए 1 का उपयोग करता हूं, तो मुझे निम्नलिखित परिणाम मिलते हैं, जो शेष मिलान दिखाता है:
id team_id name id team_id name
1 1 Laurent Dupuis 6 2 Alec Russell
2 1 Stéphane Leroy 6 2 Alec Russell
3 1 Julien le Guen 4 2 Mark Johnsson
3 1 Julien le Guen 6 2 Alec Russell