存储过程多参数解决方案

select   count(pid)   from   m_pics    
  WHERE   pPub=1    
  AND   pType=isnull(@pType,pType)    
  AND   pPixes=isnull(@pixes,pPixes)

通过isnull来解决

pType=isnull(@pType,pType)  

意思是

如果@pType is null

pType=pType

如果@pType is not null

 pType=@pType

转载于:https://www.cnblogs.com/clhed/articles/1313493.html

你可能感兴趣的:(存储过程多参数解决方案)