I don't think you understood the possible duplicate link I posted so here's the solution posted there with some trivial tweaks to suit your data.
drop table if exists usertable;
create table usertable(id int, empName varchar(3), reportsTo int);
insert into usertable values
(1 , 'XYZ' , null),
(2 , 'ABC' , 1),
(3 , 'MNP' , 2),
(4 , 'IJK' , 3),
(5 , 'PQR' , 4),
(6 , 'DEF' , 3),
(7 , 'STU' , 2);
SELECT T2.id, T2.empname,t2.reportsto
FROM (
SELECT
@r AS _id,
(SELECT @r := reportsto FROM usertable WHERE id = _id) AS parent_id,
@l := @l + 1 AS lvl
FROM
(SELECT @r := 7, @l := 0) vars,
usertable h
WHERE @r <> 0) T1
JOIN usertable T2
ON T1._id = T2.id
where t2.id <> 7
ORDER BY T1.lvl;
+------+---------+-----------+
| id | empname | reportsto |
+------+---------+-----------+
| 2 | ABC | 1 |
| 1 | XYZ | NULL |
+------+---------+-----------+
2 rows in set (0.03 sec)
and for id 6
SELECT T2.id, T2.empname,t2.reportsto
FROM (
SELECT
@r AS _id,
(SELECT @r := reportsto FROM usertable WHERE id = _id) AS parent_id,
@l := @l + 1 AS lvl
FROM
(SELECT @r := 6, @l := 0) vars,
usertable h
WHERE @r <> 0) T1
JOIN usertable T2
ON T1._id = T2.id
where t2.id <> 6
ORDER BY T1.lvl;
+------+---------+-----------+
| id | empname | reportsto |
+------+---------+-----------+
| 3 | MNP | 2 |
| 2 | ABC | 1 |
| 1 | XYZ | NULL |
+------+---------+-----------+
3 rows in set (0.00 sec)
Note I have changed reportsto from - to null for id 1. With this only works if reports to is less than id if not you will have to have some serious thought about your data structure.