不知道你所谓的多条件查询是什么?
select * from form1,form2 where xxxx=form1.xxxx and wwww=form2.wwww
这也是多条件查询的sql
不知道你想问的是不是这个?
select * from form1,form2 where xxxx=form1.xxxx and wwww=form2.wwww
这也是多条件查询的sql
不知道你想问的是不是这个?
解决方案 »
- MyEclipse无法直接重新部署
- weblogic8发布EJB错误!
- 请问这是什么意思呀?
- 关于一个数据库导出导入问题
- 用JAVA WEB START发布时下载JAR时说损坏的JAR文件,但是以前可以使用
- 请教一个SOAP的问题。
- 帮我解释一下 struts 中 struts-config.xml中的几句话阿!
- 谁有MasterEJB2这本书?
- 各位高手请多多帮忙,公司要的实在太紧,有关Jsp+servlet+ejb+sql的问题。高分
- J2EE、EJB、JAVA BEANS都有些什么内容?
- tomcat虚拟主机的配置=====================高分求解
- (100分)求 用 schema 验证 XML 的例子
public class MyQuery{
private Map map = new HashMap();
public void addQuery(String key ,String value){
//这里存入条件,比如Age,15
map.put(key,value);
}
public String getQueryString(){
StringBuffer sb = new StringBuffer();
// 这里把map转换为string,
// to do
//
return sb.toString();
}
}
String name = "zm";
String sex = "man";
String exp = "select * from employee where ";
if (age.length() >0) {
exp = exp + "age= " + age + " and ";
}
if (name.length() >0) {
exp = exp + "name='" + name + "' and ";
}
if (sex.length() >0) {
exp = exp + "sex='" + sex + "'";
//exp.lastIndexOf()
}
if(exp.lastIndexOf("and ")==exp.length() -4)
exp=exp.substring(0,exp.lastIndexOf("and ")) ; System.out.println(exp); //test
String age = "22";
String name = "zm";
String sex = "man";
String exp = "select * from employee ";
String exp1="";
if (age.length() >0) {
exp = exp + "age= " + age + " and ";
}
if (name.length() >0) {
exp = exp + "name='" + name + "' and ";
}
if (sex.length() >0) {
exp = exp + "sex='" + sex + "'";
//exp.lastIndexOf()
}
if(exp.lastIndexOf("and ")==exp.length() -4)
exp=exp.substring(0,exp.lastIndexOf("and ")) ;
if(exp1.length > 0) //修改后
exp=exp+" where "+exp1 System.out.println(exp); //test
{
String sql="select * from employee where";
if(name=="")
sql=sql+"name='"+name+"'";
if(ID=="")
sql=sql+"and ID='"+ID+"'";
if(Date=="")
sql=sql+"and Date='"+Date+"'";
if(sql=="select * from employee where")
sql="select * from employee";
return sql;
}
这样可以解决么?
{
select * from 表名 where '"+a+"' '"+b+"' '"+c+"';
}然后出JSP 页面里的下拉列表中选择你的任意查询条件