2
我正在使用IF語句來選擇SQL SELECT過程中不爲NULL的列。但是,我收到一條錯誤消息,說我的關鍵字IF附近有句法錯誤。IF語句附近的語法不正確
DECLARE @imgURL_prefix VARCHAR(100)
DECLARE @imgSmall_Suffix VARCHAR(100)
DECLARE @imgLarge_Suffix VARCHAR(100)
SET @imgURL_prefix = '//sohimages.com/images/images_soh/'
SET @imgSmall_Suffix = '-1.jpg'
SET @imgLarge_Suffix = '-2.jpg'
SELECT
P.ProductCode as ProductCode,
P.HideProduct as HideProduct,
P.Photos_Cloned_From as Photos_Cloned_From,
@imgURL_prefix +
LOWER(IF P.Photos_Cloned_From IS NOT NULL
P.Photos_Cloned_From
ELSE
P.ProductCode
END)
+ @imgSmall_Suffix as PhotoURL_Small,
@imgURL_prefix +
LOWER(IF P.Photos_Cloned_From IS NOT NULL
P.Photos_Cloned_From
ELSE
P.ProductCode
END)
+ @imgLarge_Suffix as PhotoURL_Large,
P.PhotoURL_Small as OriginalSmall,
P.PhotoURL_Large as OriginalLarge
FROM
Products_Joined P
該腳本正常工作沒有IF語句,只用LOWER(P.ProductCode)
在它的位置。
啊,謝謝。這解決了它。 –