Change value of a Select field based on another table

0

The situation that I present is not explained well.

But I have a table of matches with the following fields: Identificador , tipo de deporte , fecha , visitante and local .

Visitor and local are type int .

At the moment of making a selection, something like this remains:

1 | 1 | 01-01-1900 | 1 | 2

I have another team table with the following fields: Identificador , nombre and tipo de deporte .

I would like to be able to replace the identifier of the visiting and local team with the name found in the equipment table

    
asked by Luis Olvera 19.07.2018 в 01:27
source

1 answer

3

Your query can be solved using subqueries for the fields for which you want the detail:

select Identificador, 
       tipo de deporte, 
       fecha, 
       (select nombre from equipos where p.visitante = e.identificador) as visitante,
       (select nombre from equipos where p.local= e.identificador) as local 
from partidos p
    
answered by 19.07.2018 / 02:31
source