案例陈述中的多重标准 [英] Multiple Criteria In Case Statement

查看:28
本文介绍了案例陈述中的多重标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道你可以在这样的 case 语句中建立 1 对 1 的关系

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

而且我认为您不能在这里添加 2 个条件,但是否有可能(如果不能,我如何添加第二个条件)说

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

推荐答案

使用稍微不同的语法:

 Select case WHEN userID = '12345' And status = 'Active' Then '12' Else userID End 
 from userInformation

这篇关于案例陈述中的多重标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆