Foreign Keys Are "Breaking" Lines in Export

0

Good morning! I'm having difficulty exporting a SELECT that I created, it happens that when using INTO OUTFILE the file that is exported is breaking the lines where "Join" exists. So I ask your help so that I can solve this problem.

Note: When removing the Join's the file is exported correctly.

Example of how it was exported   

Howitshouldbeexported:

Exportedfileintxt

TheCodeUsedisasfollows:

Select 
IFNULL(Central,""),
IFNULL(DtBase,""),
IFNULL(CNPJ,""),
IFNULL(Cd,""),
IF(Tp = 1,'pessoa física - CPF', IF(TP=2,'pessoa jurídica - CNPJ',IF(TP=3,'pessoa física no exterior',IF(TP=4,'pessoa jurídica no exterior',IF(TP=5,'pessoa física sem CPF','pessoa jurídica sem CNPJ'))))) AS Tipo_de_Pessoa,
IFNULL(CongEcon,""), 
IFNULL(DetCli,""),
Contrt,
'Mod',
IFNULL('planilhas_para_consultas'.'anexo_modalidades'.Descrição_Modalidade ,"") as Descrição_Modalidades,
Cosif,
OrigemRec,
IFNULL('planilhas_para_consultas'.'anexo_4_origem_dos_recursos'.Descrição_Recursos,"") as Descrição_Recursos,
Indx,
IFNULL('planilhas_para_consultas'.'indexadores'.Descrição,"") as Descrição_Indexadores,
PercIndx

INTO OUTFILE 'C:/Cnac - Arquivos de Trabalho/Relatorios/Cooperativa/Anexos/1.1sadsadsadsad.xls'
CHARACTER SET latin1
LINES TERMINATED BY '\n'
 
from 'base_de_dados'.'base_3040' 

left join 'planilhas_para_consultas'.'anexo_modalidades' 
On 'planilhas_para_consultas'.'anexo_modalidades'.'Modalidade' = 'base_de_dados'.'base_3040'.'Mod'

left Join 'planilhas_para_consultas'.'anexo_4_origem_dos_recursos' 
on 'planilhas_para_consultas'.'anexo_4_origem_dos_recursos'.Códigos = 'base_de_dados'.'base_3040'.'OrigemRec'


left Join 'planilhas_para_consultas'.'indexadores' 
on 'planilhas_para_consultas'.'indexadores'.Códigos = 'base_de_dados'.'base_3040'.'Indx'


left Join 'planilhas_para_consultas'.'natureza_operação'
on 'planilhas_para_consultas'.'natureza_operação'.Códigos = 'base_de_dados'.'base_3040'.'NatuOp'

 WHERE 'Mod' <> 1901 and 
 Saldo_devedor <> 0 and 
 ClassOp <> 'HH' and 
 (Cnpj = @Informar_Cnpj and DtBase = @informar_Data_Base) group by id limit 3; 
    
asked by anonymous 10.04.2018 / 15:28

0 answers