zoukankan      html  css  js  c++  java
  • 多层组织机构中查询用户

    父类组织机构中查询出所有子类下的用户:

    WITH TEMPLEORZ(DeptID, ParentId,DeptName)
          AS
          (
          SELECT DeptID, ParentId,DeptName FROM dbo.tp_com_dept WHERE DeptID=3
          UNION ALL
          SELECT ORZ.DeptID,ORZ.ParentId,ORZ.DeptName
          FROM dbo.tp_com_dept AS ORZ,TEMPLEORZ AS TORZ WHERE ORZ.ParentId = TORZ.DeptID
          )
         select UserID
          ,UserName
          ,TrueName
          ,MobilePhone
          ,WorkPhone
          ,HomePhone
          ,Email
          ,QQ
          ,UserIcon, TEMPLEORZ.DeptName from tp_com_user
          join TEMPLEORZ on  tp_com_user.DeptID=TEMPLEORZ.DeptID
            where tp_com_user. DeptID in  (select DeptID from TEMPLEORZ)

  • 相关阅读:
    前端小tite(随笔)
    算法两数之和 python版
    常用标签
    pip install 遇到的问题
    不常用的模块
    约束和约束关系
    Django初识
    前端—Bootstrap
    前端—jQuery
    前端—BOM和DOM
  • 原文地址:https://www.cnblogs.com/lff255356/p/2973487.html
Copyright © 2011-2022 走看看