日期:2014-05-17 浏览次数:20523 次
--这个没问题
declare @UID int
set @UID=3
select * from T_Role_Module where RoleID
in (select RoleID from T_User_Role where UserID=@UID)
--这个有错,求教育
declare @RIDs table(RoleID int),@UID int
set @UID=3
insert into @RIDs
select RoleID from T_User_Role where UserID=@UID
select * from T_Role_Module where RoleID
in @RIDs
declare @RIDs table(RoleID int),@UID int set @UID=3 insert into @RIDs select RoleID from T_User_Role where UserID=@UID select * from T_Role_Module where RoleID in (select * from @RIDs)
DECLARE @RIDs TABLE ( RoleID INT )
DECLARE @UID INT
SET @UID = 3
INSERT INTO @RIDs
SELECT RoleID
FROM T_User_Role
WHERE UserID = @UID
SELECT A.*
FROM T_Role_Module a
INNER JOIN @RIDs b ON A.roleid = b.roleid
declare @RIDs table(RoleID int)
declare @UID int
set @UID=3
insert into @RIDs
select RoleID from T_User_Role where UserID=@UID
select * from T_Role_Module where RoleID in (select RoleID from @RIDs)