如何完成这个sql?# Database - 数据库
j*n
1 楼
我有3张table,
table: team
team_id
aa
bb
table: score
team_id game_id score status
aa 001 8 win
bb 001 5 loss
table: game
game_id
001
现在我要生成这样的结果:
team_1 score_1 status_1 team_2 score_2 status_2 game
aa 8 win bb 5 loss 001
我该怎么写sql?
我试了以下的query, 但是变成结果有2条,为
aa 8 win bb 5 loss 001
bb 5 loss aa 8 win 001
query:
select t1.team_id, s1.score, s1.status,
t2.team_id, s2.score, s2.status, g.game_id
from team t1, team t2, sc
table: team
team_id
aa
bb
table: score
team_id game_id score status
aa 001 8 win
bb 001 5 loss
table: game
game_id
001
现在我要生成这样的结果:
team_1 score_1 status_1 team_2 score_2 status_2 game
aa 8 win bb 5 loss 001
我该怎么写sql?
我试了以下的query, 但是变成结果有2条,为
aa 8 win bb 5 loss 001
bb 5 loss aa 8 win 001
query:
select t1.team_id, s1.score, s1.status,
t2.team_id, s2.score, s2.status, g.game_id
from team t1, team t2, sc