Reputation: 75
I am executing a PHP script that encodes my query into JSON format, based on a database containing matches and teams. Match table has 2 fields
(team_1 name and team_2 name as foreign keys)
while the Team table has the name of the team + logo. This is my query to get the names of the teams playing and their logo in every match:
Select m.team_1, t1.team_logo, m.team_2, t2.team_logo
From Match m, Team t1, Team t2
Where t1.name = m.team_1 and t2.name = m.team_2;
My problem is that JSON is only returning the first team name, second team logo, and second team name. Why is that? and how can I fix it?
Upvotes: 0
Views: 45
Reputation: 94
Try this:
Select
m.team_1, t1.team_logo AS logo_team1,
m.team_2, t2.team_logo AS logo_team2
From Match m, Team t1, Team t2
Where t1.name = m.team_1 and t2.name = m.team_2;
Regards
Upvotes: 1