我有4個表格,如下所示;如何執行此操作?
tbl_UserInfo DUMMY VALUES DATATYPE
UserID 1 Integer (PRIMARY KEY)
UserName A Text
FacebookID 10021556 Text
EmailID [email protected] Text
Facebook_EmailID [email protected] Text
Password welcome123 Text
Chips 100 Integer
DeviceType iphone Text
tbl_Game DUMMY VALUES DATA TYPE
GameID 1 Integer
Type H or M Text
Complete No Text
tbl_GamePlayer DUMMY VALUES DATA TYPE
ID 1 Integer (PRIMARY KEY)
GameID 1 Integer (FOREIGN KEY FOR GameID in tbl_Game)
userid 1 Integer (FOREIGN KEY FOR UserID in tbl_UserInfo)
tbl_Streaks DUMMY VALUES DATA TYPE
ID 1 Integer
GameID 1 Integer (FOREIGN KEY FOR GameID in tbl_Game)
Player1 1 Integer (FOREIGN KEY FOR UserID in tbl_UserInfo)
Player2 2 Integer (FOREIGN KEY FOR UserID in tbl_UserInfo)
Streaks 2 Integer
我想reslut作爲
{
Player1 = "A"
Player2 = 'B"
Streaks = 10 (between Player1 and Player2)
Chips = 100 (for player1)
Chips = 200 (for player2)
Fbid= 124578 (for player1)
Fbid = 784512 (for player2)
}
{
Player1 = "A"
Player3 = 'C"
Streaks = 15 (between Player1 and Player3)
Chips = 100 (for player1)
Chips = 450 (for player3)
Fbid= 5654578 (for player1)
Fbid = 7845512 (for player3)
}
{
Player1 = "A"
Player4 = 'D"
Streaks = 5(between Player1 and Player4)
Chips = 100 (for player1)
Chips = 208 (for player4)
Fbid= 12898978 (for player1)
Fbid = 78488512 (for player4)
}
我想和完整=「沒有」
顯示在用戶登錄(與他的其他球員的fbids,用戶名,芯片,條紋)的所有現有遊戲注 - userid
作爲參數傳遞和所有的球員都通過自己的用戶ID連接
列{Player1,Player2,Player3,Player4,Player5}看起來像是一個重複組。也許你應該首先規範你的數據模型。 – wildplasser
你有沒有看過,並理解,'JOIN'的美妙世界?如果不是,你是不是'看着'或'明白'?在後一種情況下,請發佈您迄今爲止創建的SQL查詢。 – jos