假设管理员名字为admin:

select *
from [DbDevice].[dbo].[Tbl_Material] t
where t.TerminalId in
(
select t11.TerminalId from [DbDevice].[dbo].[Tbl_Terminal] t11
 where t11.DealerId in
(
select t42.DealerId From [DbDevice].[dbo].[Tbl_Dealer] t42
  where t42.ParentId in
(
select t41.DealerId From [DbDevice].[dbo].[Tbl_Dealer] t41
  where t41.ParentId in
(
select t3.DealerId From [DbDevice].[dbo].[Tbl_Dealer] t3
  where t3.ParentId in
(
  select t4.DealerId From [DbDevice].[dbo].[Tbl_Dealer] t4
  where t4.ParentId in
(
select t5.PB_LOGIN_ID from [DbDevice].[dbo].[PB_STAFF] t5 where  t5.PB_PARNT_ID in
(select t6.PB_LOGIN_ID from [DbDevice].[dbo].[PB_STAFF] t6 where  t6.PB_PARNT_ID in
(select t7.PB_LOGIN_ID from [DbDevice].[dbo].[PB_STAFF] t7 where  t7.PB_PARNT_ID in
(select t8.PB_LOGIN_ID from [DbDevice].[dbo].[PB_STAFF] t8
 where t8.PB_LOGIN_ID='admin'
 )
 )
 )
 )
 )
 )
 )
 )
 );
 

posted on 2014-07-31 14:50  南湖居士  阅读(110)  评论(0)    收藏  举报