在以下查询中,我得到的子查询返回的值更多1。当子查询遵循=,!=,<,< =,>,> =或子查询用作表达式时,不允许这样做。错误
SELECT MemberID,
FirstName,
MiddleName,
LastName,
(FirstName+' '+LastName) AS FullName,
Gender,
CASE Gender
WHEN 1 THEN 'Male'
ELSE 'Female' END AS GenderName,
Phone1,
MemberNumber,
MembershipTypeID,
( SELECT MembershipTypeName
FROM MembershipTypeMaster
WHERE MembershipTypeID = MemberDetails.MembershipTypeID ) AS MemberType,
( SELECT MaxCreditLimit
FROM MembershipTypeMaster
WHERE MembershipTypeID = MemberDetails.MembershipTypeID ) AS MaxCreditLimit,
( SELECT DepositAmount
FROM MemberCreditInfo
WHERE MemberID = MemberDetails.MemberID ) AS DepositAmount,
Phone1,
Phone2,
Mobile,
EMail,
HouseNumber,
City,
MemberDetailsState,
( HouseNumber+','+City+','+MemberDetailsState+','+PinCode ) AS Address,
PinCode,
MemberPhoto,
MemberStatus,
ISNULL(( SELECT ( MaxCreditLimit - UsedCredit )
FROM MemberCreditInfo
WHERE MemberID = MemberDetails.MemberID ),0) AS BalanceCredit,
ISNULL(( SELECT UsedCredit
FROM MemberCreditInfo
WHERE MemberID = MemberDetails.MemberID ),0) AS BalanceToPay
FROM MemberDetails
WHERE MemberStatus <> 99
答案 0 :(得分:0)
这是关于你的内部选择查询。
例如,如果以下查询返回多个结果,则sql无法知道它应该写入MemberType单元格。
( SELECT MembershipTypeName
FROM MembershipTypeMaster
WHERE MembershipTypeID = MemberDetails.MembershipTypeID )