1
我的查詢看起來像自上加入表連接
Select m.cw_sport_match_id as MatchId,
m.season_id as SeasonId,
s.title as SeasonName,
c.title as ContestName
from dbo.cw_sport_match m
inner join dbo.cw_sport_season s
ON m.season_id = s.cw_sport_season_id
inner join dbo.cw_sport_contest c
ON m.contest_id = c.cw_sport_contest_id
Where s.date_start <= GETDATE() AND s.date_end >= GETDATE()
order by s.date_start
沒有我需要的sport_contest的母公司名稱(如果存在的話,它可以爲null)。所以基本上是一個自我連接,但不在查詢所在的同一張表上。所有我發現做自我連接的例子都不在另一個表上完成。 可以任何sql pro幫助我嗎? 那麼我怎樣才能加入與season_parent_id cw_sport_season本身並得到它的標題?
如果你不加入同一張表,你爲什麼稱它爲自加入?你能澄清一下嗎? – dan08
'自我加入不在另一張桌子上?如果他們在另一張桌子上,那麼它不是自聯接,而只是一個聯接。 –
okey我很抱歉,我認爲自我加入是如果我再次加入對同一張表的引用。在這種情況下,它不是自我連接,我只是想加入到連接表本身的連接表上的引用... ^^ – LaurinSt