SELECT
T2.deptid,
T2.deptname
FROM
(
SELECT
@r AS _id,
( SELECT @r := fdeptid FROM sys_dept WHERE deptid = _id ) AS fdeptid,
@l := @l + 1 AS rank
FROM
( SELECT @r := 202222, @l := -1 ) vars,sys_dept
WHERE
@r <> -1
) T1
JOIN sys_dept T2 ON T1._id = T2.deptid
ORDER BY T1.rank DESC
有没有好人帮我改一下代码 将此mysql的sql 改成金仓sql 钛难了 谢谢了