如何生成递归查询以从两个表中获取信息

How do I generate a recursive query to get information from two tables

我有一个获取所有子记录的请求

with recursive cte (id, parentId) as 
(
    select id, parentId 
    from users 
    where id = 1 

    union all 

    select p.id, p.parentId 
    from users p 
    inner join cte on p.parentId = cte.id 
) 
select * from cte

还有一个user_infotable

id, userId, login

我需要在这里查询更多信息。我该怎么做?
我尝试添加一个额外的内部连接,但没有成功。

你可以在最后加入第二个table:

with recursive cte (id, parentId) as (
    select     id,
               parentId
    from       users
    where      id = 1

    union all

    select     p.id,
               p.parentId 
    from       users p 
    inner join cte 
            on p.parentId = cte.id 
) 
select    * 
from      cte
left join user_info 
       on userId = cte.id