- select * from dbo.student
- where 1=1 ${if(len(stuName)==0,"","and stuName='"+stuName+"'")}
- ${if(len(stuNo)==0,"","and stuNo='"+stuNo+"'")}
- --使用len()方法判断参数的值是否为空,如果为空则添加连接空字符串
- --否则读取相应的参数值,进行查询,可实现多条件的添加
- //这个是判断这个参数 是不是为空
- ${if(len(stuNo)==0,"","and stuNo='"+stuNo+"'")}
- //这个是判断stuNo这个参数的数值
- ${if(stuNo==0,"","and stuNo='"+stuNo+"'")}
-
-
-
-
- ${if(len(Project_name)==0,"","AND Pro_Name LIKE '%"+Project_name+"%'")}
- ${if(len(Department_id)==0,"AND uDepart IN (SELECT ID FROM dbo.GetChild(101005))","AND uDepart IN (SELECT ID FROM dbo.GetChild("+Department_id+"))")}
- ${if(len(User_id)==0,"","AND Pro_UserId="+User_id+"")}