The problem is that the subquery does not get anything: What I want to get in the column [rs] is the name of the bank, it is currently returning null.
SELECT ta.id
,ta.idTarea
,ta.idConsignacion
,nomBanco.rs
FROM tarea_actividad AS ta
LEFT JOIN (SELECT cl.razon_social rs,
cg.bancoDestino cb
FROM consignacion cg INNER JOIN cliente cl ON (cg.bancoDestino=cl.id)) AS nomBanco
ON (ta.idConsignacion=nomBanco.cb)
WHERE ta.idTarea=333
in the table clientes.razon_social refers to the names of the banks: bbva, popular, bancolombia.
and clients.constitution: it is the way to differentiate if the client is a company or a person: natural / legal
Here is the structure of the tables
Thank you very much!