如何轉換此查詢以返回TRUE/FALSE值?TSQL轉換查詢返回TRUE/FALSE
SELECT UserID, ResumeID AS PreviouslyViewed FROM MVJ_ProfileViews
WHERE UserID = [User:UserID]
AND ResumeID = [TknParams:ResumeID]
如何轉換此查詢以返回TRUE/FALSE值?TSQL轉換查詢返回TRUE/FALSE
SELECT UserID, ResumeID AS PreviouslyViewed FROM MVJ_ProfileViews
WHERE UserID = [User:UserID]
AND ResumeID = [TknParams:ResumeID]
你可以把結果
SELECT CASE WHEN EXISTS (
SELECT UserID, ResumeID AS PreviouslyViewed
FROM MVJ_ProfileViews
WHERE UserID = [User:UserID] AND
ResumeID = [TknParams:ResumeID]
)
THEN CAST(1 AS BIT)
ELSE CAST(0 AS BIT)
END AS result
完美謝謝! – UserSN
它幫助你我的榮幸。 –
IF EXISTS (SELECT UserID, ResumeID AS PreviouslyViewed
FROM MVJ_ProfileViews
WHERE UserID = [User:UserID] AND
ResumeID = [TknParams:ResumeID])
BEGIN
SELECT 'TRUE' Result
END
ELSE
BEGIN
SELECT 'FALSE' Result
END
您當前的查詢將返回用戶的ID和繼續ID。這對TRUE/FALSE有什麼關係? –
我試圖確定'UserID = 1'是否查看過'ResumeID = 1',然後返回'true',否則'false' – UserSN