2013-07-26 44 views
2

我命名爲時序,包含以下的事情是否有任何Sqlite選擇查詢獲取兩個表的結果?

Id Team1  Team2   MD   MT 
1 Name1  Name2 26/07/2013 10.00 
2 Name3  Name4 26/07/2013 11.00 

另一個名爲Players的表

Id  Name Email 
Name1 Naveen email 
Name2 Bos  email 
Name3 Sharath email 
Name4 mohan email 

,我需要得到像這樣的表,是否有可能得到的結果在一個查詢?

MD   MT  PlayerName1 playername2 
26/07/2013 10.00 Naveen  Bos 
+0

可能重複:http://stackoverflow.com/questions/17843202/how-do-i-combine-data-from-two-separate-tables -into-a-single-cursor/17843427#17843427 – TronicZomB

+1

使用JOIN並完成它 –

+0

'id'在兩行上真的具有值'Name3'嗎? –

回答

2

嘗試雙join如下

select T.MD,T.MT,P1.Name as PlayerName1, P2.Name as playername2 
from Timings T 
join Players P1 on P1.Id = T.Team1 
join Players P2 on P2.Id = T.Team2 
相關問題