sql - Ignore other results if a resultset has been found -
to start, take snippet example:
select * statsvehicle ((referencemakeid = @referencemakeid) or @referencemakeid null)
this fetch , filter records if variable @referencemakeid not null, , if null, fetch records. in other words, taking first 1 consideration if @referencemakeid not null.
i add further restriction this, how can achieve this?
for instance
(referencemodelid = @referencemodeleid) or ( (referencemakeid = @referencemakeid) or (@referencemakeid null) )
if @referencemodelid not null, need filter referencemodelid, , ignore other statements inside it. if such, returns records. there can done achieve such thing?
maybe this?
select * statsvehicle ( -- removed following, it's not clear if beneficial -- (@referencemodeleid not null) , (referencemodelid = @referencemodeleid) ) or (@referencemodeleid null , ( (referencemakeid = @referencemakeid) or (@referencemakeid null) ) )
Comments
Post a Comment