簡體   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