我有以下代码 -
declare @userType int
declare @custIdOfUser int
select
@userType = UserTypeId, @custIdOfUser = CustomerId
from
customers c with (nolock)
left outer join
Sites s with (nolock) on c.CustomerId = s.CustomerId
left outer join
customers rc on rc.CustomerId = c.ResellerId
where
c.[name] is not null
and (c.customerId is null or rc.CustomerId = c.CustomerId)
and c.IsActive != ''
and (@userType = 1 OR @userType = 2 OR
(c.customerId in ((SELECT u.CustomerId, ur.RoleId
FROM Users u
INNER JOIN UserRoles ur ON ur.UserId = u.UserId AND ur.RoleId = 39
INNER JOIN Customers c ON ur.CustomerId = c.CustomerID
WHERE u.UserId = 28 or u.UserTypeId = 3 or u.UserTypeId = 4
and c.customerId in
(SELECT c.CustomerId FROM Customers c
WHERE c.resellerId = u.CustomerId )))))
它给了我以下错误消息-
Msg 116, Level 16, State 1, Line 10
当子查询没有用 EXISTS 引入时,只能在选择列表中指定一个表达式。
消息 207,级别 16,状态 1,第 3 行
无效的列名称“UserTypeId”。
消息 209,级别 16,状态 1,行 3
不明确的列名称“客户 ID”。