0
I have a Mysql Query that only returns me Error Code: 2013. Lost connection to MySQL server during query
.
Follows the same:
select log_logradouro.ufe_sg, log_localidade.LOC_NU, log_localidade.LOC_NU_SUB, log_localidade.loc_no, log_bairro.bai_no, CONCAT(log_logradouro.tlo_tx, " ", log_logradouro.log_no) as log_no, log_logradouro.cep, log_logradouro.log_complemento,"" AS nome, log_localidade.MUN_NU, log_num_sec.SEC_NU_INI, log_num_sec.SEC_NU_FIM, log_num_sec.SEC_IN_LADO
from log_logradouro, log_localidade, log_bairro, log_num_sec
where log_logradouro.loc_nu= log_localidade.loc_nu and log_logradouro.bai_nu_ini=log_bairro.bai_nu and log_logradouro.log_sta_tlo ="s"
union
select log_logradouro.ufe_sg, log_localidade.LOC_NU, log_localidade.LOC_NU_SUB, log_localidade.loc_no, log_bairro.bai_no, log_logradouro.log_no as log_no, log_logradouro.cep, log_logradouro.log_complemento,"" AS nome, log_localidade.MUN_NU, log_num_sec.SEC_NU_INI, log_num_sec.SEC_NU_FIM, log_num_sec.SEC_IN_LADO
from log_logradouro, log_localidade, log_bairro, log_num_sec
where log_logradouro.loc_nu= log_localidade.loc_nu and log_logradouro.bai_nu_ini=log_bairro.bai_nu and log_logradouro.log_sta_tlo ="n"
union
SELECT LOC.UFE_SG, LOC.LOC_NU, LOC.LOC_NU_SUB, LOC.LOC_NO, "" AS BAI_NO, "" AS LOG_NO, LOC.CEP, "" AS LOG_COMPLEMENTO, "" AS NOME, LOC.MUN_NU AS MUN_NU, SEC.SEC_NU_INI AS SEC_NU_INI, SEC.SEC_NU_FIM AS SEC_NU_FIM, SEC.SEC_IN_LADO AS SEC_IN_LADO
FROM LOG_LOCALIDADE AS LOC, log_num_sec AS SEC
WHERE LOC.CEP IS NOT NULL
UNION
SELECT LOC.UFE_SG, LOC.LOC_NU AS LOC_NU, LOC.LOC_NU_SUB AS LOC_NUM_SUB, LOCSUB.LOC_NO AS LOC_NO, LOC.LOC_NO AS BAI_NO, "" AS LOG_NO, LOC.CEP, "" AS LOG_COMPLEMENTO, "" AS NOME, LOC.MUN_NU AS MUN_NU, SEC.SEC_NU_INI AS SEC_NU_INI, SEC.SEC_NU_FIM AS SEC_NU_FIM, SEC.SEC_IN_LADO AS SEC_IN_LADO
FROM LOG_LOCALIDADE AS LOC, LOG_LOCALIDADE AS LOCSUB, log_num_sec AS SEC
WHERE LOC.CEP IS NOT NULL
AND LOC.LOC_NU_SUB IS NOT NULL
AND LOC.LOC_NU_SUB = LOCSUB.LOC_NU
union
select log_cpc.ufe_sg, log_localidade.LOC_NU, log_localidade.LOC_NU_SUB, log_localidade.loc_no,""
as bai_no, log_cpc.cpc_endereco as log_no, log_cpc.cep,"" as log_complemento,cpc_no AS nome, log_localidade.MUN_NU, log_num_sec.SEC_NU_INI, log_num_sec.SEC_NU_FIM, log_num_sec.SEC_IN_LADO
from log_cpc, log_localidade, log_num_sec
where log_cpc.loc_nu=log_localidade.loc_nu
union
select log_grande_usuario.ufe_sg, log_grande_usuario.LOC_NU, log_localidade.LOC_NU_SUB, log_localidade.loc_no, log_bairro.bai_no as bai_no, log_grande_usuario.gru_endereco as log_no, log_grande_usuario.cep,"" as log_complemento,gru_no AS nome, log_localidade.MUN_NU AS MUN_NU, log_num_sec.SEC_NU_INI AS SEC_NUM_INI, log_num_sec.SEC_NU_FIM AS SEC_NUM_FIM, log_num_sec.SEC_IN_LADO AS SEC_IN_LADO
from log_grande_usuario, log_localidade, log_bairro, log_num_sec
where log_grande_usuario.loc_nu=log_localidade.loc_nu and log_grande_usuario.bai_nu = log_bairro.bai_nu
union
select log_unid_oper.ufe_sg, log_localidade.LOC_NU, log_localidade.LOC_NU_SUB, log_localidade.loc_no, log_bairro.bai_no as bai_no, log_unid_oper.uop_endereco as log_no, log_unid_oper.cep,"" as log_complemento, uop_no AS nome, log_localidade.MUN_NU AS mun_nu, log_num_sec.SEC_NU_INI AS SEC_NUM_INI, log_num_sec.SEC_NU_FIM AS SEC_NUM_FIM, log_num_sec.SEC_IN_LADO AS SEC_IN_LADO
from log_unid_oper, log_localidade, log_bairro, log_num_sec
where log_unid_oper.loc_nu=log_localidade.loc_nu and log_unid_oper.bai_nu = log_bairro.bai_nu;
This is the DER of the database:
What is wrong with my Query, which does not execute?
See manual: https://dev.mysql.com/doc/refman/8.0/en/gone-away.html
– anonimo
possible problem of timeout, the query took too long to execute. See how to increase the limit of timeout to be able to execute, or improve the performance of the query
– Ricardo Pontual