sql 语句是 WITH RECURSIVE subordinates AS ( SELECT uid,parent_uid,org_name FROM organizationcopy WHERE uid = '3f525f4334a44678aab5d4b80dc8cb30' UNION ALL SELECT e.uid, e.org_name, e.parent_uid FROM organizationcopy e JOIN subordinates s ON e.parent_uid = s.uid ) SELECT uid, parent_uid, org_name FROM subordinates;
时间: 2024-03-13 13:46:06 浏览: 147
sql语句的用法
根据你提供的 SQL 语句,可以看出你是想使用 WITH RECURSIVE 子句来进行递归查询。但是,根据错误提示,似乎是缺少了关键字 WITH,导致语法解析错误。
我看到你的 SQL 语句中,第一行是 WITH RECURSIVE 子句,但是后面的代码中缺少了 WITH 关键字,应该是因为复制粘贴时出现了问题。
请将你的 SQL 语句修改为以下代码并重新执行:
```
WITH RECURSIVE subordinates AS (
SELECT uid, parent_uid, org_name
FROM organizationcopy
WHERE uid = '3f525f4334a44678aab5d4b80dc8cb30'
UNION ALL
SELECT e.uid, e.parent_uid, e.org_name
FROM organizationcopy e
JOIN subordinates s ON e.parent_uid = s.uid
)
SELECT uid, parent_uid, org_name
FROM subordinates;
```
这样应该就能够正常执行了。
阅读全文