我需要在內部編寫case語句,條件是類似的。如何在SQL服務器中的where語句中編寫大小寫
"If color equel to 'RED' then return all the flowers including red"
else "return all flowers which are not RED"
我需要包括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(@Color ='Red')OR(@Color <>'Red'AND Flower.Color <>'Red')'? –
「顏色」/「它」來自哪裏?它是傳遞給此查詢的變量嗎? –
是的,它作爲參數傳遞給SP – Naruto