How to change the id of a column by name in the same table in MySQL?

0

I want to give a select and instead of receiving the top_default number I want the name of it that is nm_depto. How can I do this?

SELECT d.id_numero_depto, d.nm_depto, d.id_numero_depto_superior FROM tb_depto AS d;
    
asked by anonymous 09.10.2017 / 00:42

1 answer

0

I managed, this was the code:

select d1.id_numero_depto, d1.nm_depto, d2.nm_depto from tb_depto d1, tb_depto d2 where d1.id_numero_depto_superior = d2.id_numero_depto and d1.id_numero_depto_superior is not null;    
    
09.10.2017 / 01:40