1
我的表如下所示:與多個結果連接兩個表放在一個表
tbl_teams
id, teamname, created
tbl_teamstats
id, rank, rating, wins, losses, tbl_teams_id, created
我想根據tbl_teamstats這兩個表合併在一起「創建遞減限制1」 例如查詢
SELECT TS.*, T.* FROM tbl_teamstats as TS
LEFT JOIN tbl_teams as T
ON T.id = TS.tbl_teams_id
會回到這樣的事情
TS.id TS.rank TS.rating TS.wins TS.losses T.id T.teamname T.created
14871 2 2522 168 26 2 teamname1 23/02/2017 17:55
14688 2 2540 168 25 2 teamname1 23/02/2017 17:55
2683 2 2535 167 25 2 teamname1 23/02/2017 17:55
2612 2 2529 166 25 2 teamname1 23/02/2017 17:55
2590 2 2523 165 25 2 teamname1 23/02/2017 17:55
2448 2 2517 164 25 2 teamname1 23/02/2017 17:55
2346 2 2511 163 25 2 teamname1 23/02/2017 17:55
234 2 2505 162 25 2 teamname1 23/02/2017 17:55
1 1 2570 171 19 1 teamname2 23/02/2017 17:55
WH在我希望它看起來像:
TS.id TS.rank TS.rating TS.wins TS.losses T.id T.teamname T.created
14871 2 2522 168 26 2 teamname1 23/02/2017 17:55
1 1 2570 171 19 1 teamname1 23/02/2017 17:55
(只顯示來自tbl_teamstat由TS.id訂購一個結果)
可能有人請幫助我,或點我在正確的方向?將不勝感激!
謝謝添加
GROUP BY
條款!這解決了它:) –