I use the TableAdapter Configuration Wizard under VS2008 and use SQL Server Express.
This is my database diagram:
And this is my SELECT statement:
SELECT Parties.PartieID, Parties.RondeID, Parties.JoueurNoirID, Parties.JoueurBlancID, Parties.ScoreNoir, Parties.ScoreBlanc, Parties.VainqueurID,
Parties.DetailVictoire, Rondes.Numero, Tournois.Nom, [B](SELECT Pseudonyme FROM Joueurs WHERE JoueurID = Parties.JoueurNoirID) AS JoueurNoir, (SELECT Pseudonyme FROM Joueurs WHERE JoueurID = Parties.JoueurBlancID) AS JoueurBlanc, (SELECT Pseudonyme FROM Joueurs WHERE JoueurID = Parties.VainqueurID) AS Vainqueur[/B]
FROM Parties INNER JOIN
Rondes ON Parties.RondeID = Rondes.RondeID INNER JOIN
Tournois ON Rondes.TournoiID = Tournois.TournoiID INNER JOIN
Joueurs ON Parties.JoueurBlancID = Joueurs.JoueurID AND Parties.JoueurNoirID = Joueurs.JoueurID AND Parties.VainqueurID = Joueurs.JoueurID
First, how to formulate to use JOINS instead of the SELECTs on Joueurs subqueries?
Second, is it the best to have three foreign keys related to the same parent indexed field? (i don't see how to do differently)
Any help would be very appreciated.
Greetings,
Nicolas