我有表Acc_Region
。
我需要选择与Parent -Delta Sector相关的所有节点 - 当我使用查询
时select Name from Acc_Region where ID = 1
获取所有引用
Cairo
Faysl City
Helwan City
Giza
Aiat
Saf
我尝试使用:
WITH RECURSIVE Region (ID, name, Parent_ID) AS
(
SELECT ID,
name,
Parent_ID
FROM ACC_REGION
UNION ALL
SELECT Acc.ID,
Acc.name,
Acc.Parent_ID
FROM ACC_REGION Acc
JOIN Region Reg ON Acc.userid = Reg.managerid
)
SELECT *FROM ACC_REGION
但是RECURSIVE
存在问题。
有什么方法可以解决这个问题吗?
答案 0 :(得分:1)
这就是应该如何构造递归CTE:
<div id="gauge" class="400x260px"></div>
<!---The Form--->
<form class="form-inline" action="" id="myform" form="" method="post">
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="total"></label>
<div class="col-md-8">
<input id="total" name="total" type="text" placeholder="total" class="form-control input-lg" required>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit1"></label>
<div class="col-md-4">
<button id="submitButtonId" name="submit1" class="btn btn-primary btn-xl">Submit</button>
</div>
</div>
</form>