select * from pbx_classifica_reg limit 10 select * from pbx_classifica_atendimento select coalesce(c.clas_descricao, 'NI') as clas_descricao, coalesce(b.matricula, 'NI') as matricula, b.data_reg, a.* from pbx_protocolo_reg a left outer join pbx_classifica_reg b on b.id_bilhetes = a.uniqueid left outeR join pbx_classifica_atendimento c on c.clas_id = b.clas_id where exists(select '' from tmp_proto_pesquisa where num_protocolo = a.protoparceiro)