Problems with select in multiple tables

Asked

Viewed 115 times

3

I’m trying to make the conversion of a select from sql server to Dapper, as it was very big, I’m wanting to leave more lean and readable... However this appearing error in some passages

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 in 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
  • 2

    You have a inner join to a table that has already been listed. then it is lost in which to use, alias or without.

  • 1

    your select ta very messy, you start one way and then start using Inner Join.. user one thing or another.

  • @Gokussjgod, really... I changed the select and it brought me the same fields and it became even cleaner visibly... :)

  • 1

    already corrected, you can post as corrected or delete the question.

  • SELECT email.subject [Subject], Disp.cod_trigger [Disparadorid], p.Desc_person [Descricaopessof], ee.cod_Email_Auto_Config_Disparador_Email_Empresa [Emaildisparadorconfigid] FROM Cl2_email_auto_config_triggeror_email, Cl2_email_auto_config_trigger Disp, Cl2_person p, Cl2_email_auto_config_trigger_email_company ee WHERE (Disp.cod_trigger = 2) Only left without formatting hehehe Thanks @Guilhermelautert and @Gokussjgod!!!

  • @Mfilho_19 does not post as a comment, post as a reply and accept it.

  • @Genos I don’t understand, I could explain better?

  • 1

    @Mfilho_19 Instead of posting the solution as a comment, use the button below (I believe for the owner of the question to be something like 'Answer my question') to post the solution as an official answer. Then accept that answer.

Show 3 more comments

1 answer

0

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) 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.