17,086
社区成员
发帖
与我相关
我的任务
分享
select * from Sometable where (ID="+stuID+" or "+stuID+" is null) and (Name ='" + stuName + "' or '" + stuName + "' is null) and (Age="+stuAge+" or "+stuAge+" is null)";
string str="select * from Sometable where 1=1";
if(stuID != null && !stuID.trim().equals("")){
str = str+" and ID = "+stuID;
}
if(stuName != null && !stuName.trim().equals("")){
str = str+" and Name = "+stuName;
}
if(stuAge!= null && !stuAge.trim().equals("")){
str = str+" and Age= "+stuAge;
}