sql server 2008 - IF ELSE CONDITION IN SQL WHERE CLAUSE -
my query
declare @autoapprove bit set @autoapprove = ( select autoapprove dbo.commentbox_setting usermoduleid = @mymoduleid , portalid = @portalid , culturecode = @culturecode )
from whether 1 or 0 (true or false) furthermore have
select * comentbox_comment uppermoduleid = @uppermoduleid , moduleid = @mymoduleid , portalid = @portalid , culturecode = @culturecode , //here need check condition
(if(@autoapprove=0){ isapprove=1}else {do not check})
note here isapprove table filedname
i know ,i can long query need short , easy way. me out.
try like
and case when @autoapprove=0 isapprove else 1 end = 1
this check isapprove = 1
if @autoapprove = 0
, or 1=1(ignore)
otherwise.
Comments
Post a Comment