Reputation: 37
I have two tables, one is Players and second one is Participant's List. I keep full data about player only in Players table and i want to display Participant's data but i don't want to show ID, which are stored in this table. I want to replace them with data relevant to stored ID. So i wrote script:
SELECT pl.surname as Name FROM players pl, participants_list p
WHERE pl.player_id = p.player_id
And it works, but it replaces only one value which is the name of player. I need to replace also name of the tournament from other table. I don't know how to combine those two operations, which may result in getting 2 columns replaced with value. For example
Smith | Tournament 1
Kowalsky | Tournament 2
The data I have is:
Players Table
Player's id|Player's Name| and more
Events Table
Event's id|Event's Name| and more
Participant's Table
Player's id|Event's id
Upvotes: 0
Views: 40
Reputation: 1171
Try this out:
select b.player_name,c.event_name
from
Participants_table a
left join
players table b
on a.player_id = b.player_id
left join
events_table c
on a.event_id = c.event_id;
Let me know in case of any queries.
Upvotes: 1