开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜