表1, tb_team
id name表2, tb_subscription
username teamId表3, tb_match
id hostTeamId awayTeamId 现在我就想获取到主客场球队的信息以及match的所有信息,sql语句应该怎么写?
id name表2, tb_subscription
username teamId表3, tb_match
id hostTeamId awayTeamId 现在我就想获取到主客场球队的信息以及match的所有信息,sql语句应该怎么写?
select * from tb_subscription a left join teamId b on a.teamId=b.hostTeamId
left join teamId c on a.teamId=c.awayTeamId
where a.username='123'
from tb_match m ,tb_team h , tb_team a, tb_subscription s
where m.hostTeamId=h.id and m.awayTeamId=a.id
and m.hostTeamId=s.teamId and m.awayTeamId=s.teamId
贴建表及插入记录的SQL,及要求结果出来看看
from tb_match m ,tb_team h , tb_team a, tb_subscription s
where m.hostTeamId=h.id and m.awayTeamId=a.id
and (m.hostTeamId=s.teamId or m.awayTeamId=s.teamId)