neo*_*key 0 sql t-sql sql-server sql-server-2008
是否有可能使用IF-ELSE或类似的东西做这样的事情:
SELECT
MemberID,
ProfileTypeID
PrCountryID, -- 3
PrStateID, -- 4
PrStateInt
FROM Member
WHERE PrCity IS NOT NULL
IF @ShowUnclaimed = 'N'
AND Claimed = 'Y'
AND SBIcon = 'N'
END
AND Viewable = 'Y'
AND SystemID = 2
Run Code Online (Sandbox Code Playgroud)
非常感谢任何信息.
neojakey
没有必要使用Case这个
SELECT
MemberID,
ProfileTypeID
PrCountryID, -- 3
PrStateID, -- 4
PrStateInt
FROM Member
WHERE PrCity IS NOT NULL
AND Viewable = 'Y'
AND SystemID = 2
AND ( @ShowUnclaimed != 'N'
OR ( Clamed = 'Y' AND SBIcon = 'N' )
)
Run Code Online (Sandbox Code Playgroud)