2016年4月28日 星期四

SQL Server: Two table reference each other field correspond.

一表中,若欄位皆以ID取代,要將其ID全部替換成真實的 Full Name,可參照:




SELECT G.Home, G.Away, 
C1.CountryName, C2.CountryName

FROM Game G
JOIN Country C1 ON C1.CountryID = G.Home
JOIN Country C2 ON C2.CountryID = G.Away;

Reference:
http://stackoverflow.com/questions/4267929/whats-the-best-way-to-join-on-the-same-table-twice

沒有留言:

張貼留言

© ERIC RILEY , 自由無須告知轉貼
Background Japanese Sayagata by Olga Libby