繁体   English   中英

如何在SQL Server中的where语句中编写大小写

[英]How to write case in where statement in sql server

我需要在内部编写case语句,条件是类似的。

"If color equel to 'RED' then return all the flowers including red" 
 else "return all flowers which are not RED"

我需要将此语句包含在where子句中,我的where语句看起来像这样

Select Plant, leafs, places
from dbo.tblplant, dbo.tblflower,dbo.tblplaces
where dbo.tblplant = ID and
dbo.tblplaces = PLACE and
dbo.tblflower = REDCOLOR.

我需要以某种方式修改而不是redcolor,即查询应返回所有花朵(如果红色),否则应排除红色花朵并返回休息。

where  @colorParameter = 'RED' 
       or ( @colorParameter <> 'RED' and tblplant.color <> 'RED')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM