Need help with TSQL proc
So I have a mapping table of tournaments to teams. All this table has is TeamId and TournamentId.
I have a proc, GetTournamentsByTeam that takes in @TeamId int
Basically I want to get all the tournament records from tblTournament using all the TournamentId's I get from开发者_如何学C the mapping table where the TeamId = @TeamId.
How would I do this?
What you want to do is an inner join between the tables.
SELECT tournament.*
FROM tblTournament tournament
INNER JOIN tblTournamentTeams tt ON tournament.TournamentId = tt.TournamentId
WHERE tt.TeamId = @TeamId
What you want to do is read any SQL book for beginners. Seriously.
精彩评论