R
R
RomanCasper2015-01-06 11:18:21
PHP
RomanCasper, 2015-01-06 11:18:21

How to make a MySql query from two tables?

There are two tables:
archive_games(id, first_team, second_team, tournament, date, team_winner)
teams(id, team_name, src_team_logotype)

You need to make a selection so that the array (mysql_fetch_row) turns out like this:
id (from the archive_games table) , first_team, src_team_logotype ( for first_team) , second_team, src_team_logotype (for second_team) , tournament, date, team_winner
In other words, I need to add team logos to the first table, take logos where first_team and second_team match team_name .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2015-01-06
@gbg

select 
t1.id,
t1.logotype,
t2.id,
t2.logotype
--остальные колонки
from archive_games 
left join teams t1 on t1.id=archive_games.first_team
left join teams t2 on t2.id=archive_games.second_team

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question