Multiple Criteria In Case Statement [duplicate]

2019-09-17 05:38发布

This question already has an answer here:

I know you can do a 1 to 1 relationship in a case statement like such

Select case userID when '12345' Then '12' Else userID End from userInformation

and I don't think you can add 2 criteria in here, but is it possible (if not how could i add a 2nd criteria) to say

Select case userID when '12345' And status is 'Active' Then '12' Else userID End from userInformation

1条回答
祖国的老花朵
2楼-- · 2019-09-17 06:35

Use a slightly different syntax:

 Select case WHEN userID = '12345' And status = 'Active' Then '12' Else userID End 
 from userInformation
查看更多
登录 后发表回答