I have three tables servicios
, usuarios
e instaladores2
, as shown here:
usuarios servicios instaladores2
--------------- --------------------- --------------
id_usuario id_contrato id_instalador
nombre_completo nombre_cliente nombre_completo
domicilio_instalacion
colonia
poblacion
telefono_local
telefono_cel_1
telefono_cel_2
telefono_cel_3
nombre_contacto
Comentario
hora_instalacion
cita_confirmada
id_instalador
id_gestiono
I need to make a query that brings me the name of who I manage, at the moment I have the code like this:
$sql = "SELECT
'id_contrato',
'nombre_cliente',
'domicilio_instalacion',
'colonia',
'poblacion',
'telefono_local',
'telefono_cel_1',
'telefono_cel_2',
'telefono_cel_3',
'nombre_contacto',
'Comentario',
ti.nombre_completo as instalador,
hora_instalacion,
cita_confirmada
FROM
'bd_servicios' as tc
inner join
bd_instaladores2 as ti on (tc.id_instalador = ti.id_instalador)
WHERE
fecha_instalacion = '$fecha_instalacion'
$where
ORDER BY
instalador, hora_instalacion
;";
What up to now does this code that does work, is a list of the services and I pull the name of the installer from the table instaladores2
, since in the table servicios
I only store the id_instalador
.
Now what I need is that from the id_gestiono
field, which is stored in the servicios
table, get the name from the user table, which is in the nombre_completo
field.