SELECT t3.id,t3.name FROM ( SELECT t1.id,t1.name, IF ( FIND_IN_SET( t1.parent_Id, @pids ) > 0, @pids := CONCAT( @pids, ',', t1.id ), 0 ) AS ischild FROM ( SELECT t.id,t.name,t.parent_id FROM idaas_department t ORDER BY parent_Id, id ) t1,( SELECT @pids := '8a8a80867baa3f2b017baa465d8a0001' ) t2 ) t3 where ischild != 0 给我转化成SQL语句
时间: 2023-06-25 13:04:25 浏览: 205
这已经是 SQL 语句了,只不过使用了子查询和变量。以下是同样功能的 SQL 语句,不使用子查询和变量:
SELECT t3.id, t3.name
FROM idaas_department t3
JOIN idaas_department t2 ON FIND_IN_SET(t3.parent_Id, t2.id)
WHERE t2.id = '8a8a80867baa3f2b017baa465d8a0001';
阅读全文