I have Tables A and B. In B I have two fields that contain the Ids of A to make relationships in a php report. However I run into a problem: that I can not do a INNER JOIN
to show those two fields;
TABLA-A
id Nombre
================
1 Andres
2 Juan
TABLA-B
id id_Primer_persona id_Segunda_persona
===================================================
1 1 2
Well then, I have those two tables. In A I have the data of the person and B is a table that can have two people per record (these tables are for example, the real ones have a lot of data and I can not change the development). I would normally do this INNER JOIN
:
SELECT tablaB.id, tablaA.nombre as Nombre1
FROM tablaB
INNER JOIN tablaA on tablaA.id = tablaB.id_Primer_persona
Result:
id nombre1
==========
1 Andres
That code works to get the first person, but then, if I want to take a record that shows me the name of the first and second person, how do I do it? Thanks.