我正在尝试将IF
.. ELSE
inWHERE
子句如下所示,但收到错误消息
“关键字 'IF' 附近的语法不正确。')' 附近的语法不正确。”
DECLARE @categoryID int
SET @categoryID = 0
SELECT * from SE_Auctions
WHERE ItemCategoryID IN
(
IF @categoryID = 0
SELECT CategoryID from SE_ItemCategory
ELSE
SELECT CategoryID from SE_ItemCategory
WHERE ParentID = @categoryID
OR CategoryID = @categoryID
)