with tab as ( select a.Id,a.ParentId,a.Name,a.Vieworder from dbo.Area a where Id in(select Id from Area a where a.Name like '%科尔%')--=421381--子节点 union all select b.Id,b.ParentId,b.Name,b.Vieworder from tab a,--子节点数据集 dbo.Area b --父节点数据集 where a.ParentId=b.Id --子节点数据集.parendID=父节点数据集.ID ) select distinct Id,ParentId,Name,Vieworder from tab ;
以上是从网上找来,模糊找name时,把它所有父节点找出来。
<html> <head> <title>系统</title> @Html.Partial("CommonJSAndCSS") </head>
CommonJSAndCSS 位于/Views/Shared 下
<link href="@Url.Content("~/Styles/test.css")" rel="stylesheet" type="text/css" /> <script src="@Url.Content("~/Scripts/jquery-1.8.0.min.js")" type="text/javascript"></script>