szufi szufi - 6 months ago 11
SQL Question

SQL ,How to connect two IDs with name in SQL

I have two tables.

FIRST Table "Player" contains:

Player_id;
Name;
Surname;


SECOND Table "Substitutions" contains:

Sub_id;
In_player_id;
Out_player_id;


And now i want to print name and surname of
in_player_id
and of
out_player_id
using
select
in
sql
language

Answer

This can be done using two JOINs:

SELECT INPLAYER.Name, INPLAYER.Surname, OUTPLAYER.Name, OUTPLAYER.Surname
FROM Substitutions
INNER JOIN Player AS INPLAYER ON (Substitutions.In_player_id = INPLAYER.Player_id)
INNER JOIN Player AS OUTPLAYER ON (Substitutions.Out_player_id = OUTPLAYER.Player_id)

I removed "AS" keyword and it worked in Oracle