sql 多条件查询

来源:互联网 发布:用r语言做数据分析选举 编辑:程序博客网 时间:2024/05/30 23:08

 

SELECT * FROM ET_TrainingFile  where
( @fileName is null or len(@fileName)=0 or FileName like  '%'+@fileName+'%' )
and
( @type is null or len(@type)=0 or type =@type )
and
( @Country is null or len(@Country)=0 or Country =@Country )

and ( @directoryId is null or len(@directoryId)=0 or directoryid=@directoryId or directoryId in( select Id from c_tree(@directoryId)  ))

原创粉丝点击