sql – Problems with select on multiple tables

Question:

I'm trying to convert a select from sql server to Dapper, as it was too big, I'm trying to make it leaner and readable… But an error is appearing in some parts

SELECT
    email.assunto [Assunto],
    disp.cod_disparador [DisparadorID],
    p.Desc_Pessoa [DescricaoPessoa],
    ee.cod_Email_Auto_Config_Disparador_Email_Empresa [EmailDisparadorConfigID]
FROM 
    CL2_Empresa emp,
    CL2_Email_Auto_Config_Disparador_Email email,
    CL2_Email_Auto_Config_Disparador disp,
    CL2_Pessoa p,
    CL2_Email_Auto_Config_Disparador_Email_Empresa ee 
INNER JOIN  CL2_Email_Auto_Config_Disparador_Email_Empresa 
    ON CL2_Empresa.Cod_Empresa = ee.Cod_Empresa 
INNER JOIN  CL2_Pessoa 
    ON CL2_Empresa.Cod_Pessoa = CL2_Pessoa.Cod_Pessoa 
RIGHT OUTER JOIN    CL2_Email_Auto_Config_Disparador 
INNER JOIN  CL2_Email_Auto_Config_Disparador_Email 
    ON CL2_Email_Auto_Config_Disparador.cod_disparador = CL2_Email_Auto_Config_Disparador_Email.cod_disparador 
    ON ee.cod_disparador_email = CL2_Email_Auto_Config_Disparador_Email.cod_disparador_email
WHERE 
    (disp.cod_disparador = 2)

But on these two lines, the error message appears:

(the mult-part identifier "field name" could not be bound)

CL2_Email_Auto_Config_Disparador_Email_Empresa ON CL2_Empresa.Cod_Empresa = ee.Cod_Empresa INNER JOIN CL2_Pessoa ON CL2_Empresa.Cod_Pessoa = CL2_Pessoa.Cod_Pessoa RIGHT OUTER JOIN

Answer:

SELECT email.assunto [Assunto]
      ,disp.cod_disparador [DisparadorID]
      ,p.Desc_Pessoa [DescricaoPessoa]
      ,ee.cod_Email_Auto_Config_Disparador_Email_Empresa [EmailDisparadorConfigID] 
FROM  CL2_Email_Auto_Config_Disparador_Email email 
     ,CL2_Email_Auto_Config_Disparador disp
     ,CL2_Pessoa p 
     ,CL2_Email_Auto_Config_Disparador_Email_Empresa ee 
WHERE (disp.cod_disparador = 2) 
Scroll to Top