I have a table where I want to get all rows recurrsively based on `id` and `upline_id` (parent id) fields. This has been done in PostgreSQL like this:

```
WITH RECURSIVE downlines(id, number, upline_id, first_name, last_name, level) AS (
  SELECT id, number, upline_id, first_name, last_name, 1
  FROM mytable
  WHERE id = 2061
  UNION ALL
  SELECT a.id, a.number, a.upline_id, a.first_name, a.last_name, d.level + 1
  FROM mytable a, downlines d
  WHERE a.upline_id = d.id
)

SELECT * from downlines

```

However I am new to MySQL and cannot figure out how to convert above query into MySQL version. I found this for MySQL:

```
select  *
from    (select * from agents order by id) products_sorted,
        (select @pv := '2061') initialisation
where   find_in_set(upline_id, @pv) > 0
and     @pv := concat(@pv, ',', id)

```

However results do not match, in MySQL version many rows are missing.

Can anybody tell how do I convert above PostgreSQL query to MySQL to get recursive/hierarchical (n/unknown depth) data?