我用的是jsp+oracle
for (int i = 0;i<mednames.length;i++ ) {
//out.print(mednames[i]);
if (mednames[i].equals("1")) {
strsql1 = " select drugid from drugname where drugtym like '"+drugtym+"%'";
}
else if (mednames[i].equals("2")) {
strsql1 = strsql1 + " union select drugid from drugname where drughxm like '"+drugtym+"%'";
}
else if (mednames[i].equals("3")) {
strsql1 = strsql1 + " union select drugid from drugname where drugspm like '"+drugtym+"%'";
}
else if (mednames[i].equals("4")) {
strsql1 = strsql1 + " union select drugid from drugname where drugbm like '"+drugtym+"%'";
}
else if (mednames[i].equals("5")) {
strsql1 = strsql1 +" union select drugid from drugname where drugldm like '"+drugtym+"%'";
}
else if (mednames[i].equals("6")) {
strsql1 = strsql1 + " union select drugid from drugname where drugywm like '"+drugtym+"%'";
}
else if (mednames[i].equals("7")) {
strsql1 = strsql1 + " union select drugid from drugname where drugpym like '"+drugtym+"%'";
}
else {
strsql1 = strsql1 + " union select n.drugidfrom drugname n,drugcyname c where n.drugid =c.drugid and c.drugcym like '"+drugtym+"%'";
}
用以上的sql我可能要生成5000-10000或许更多的语句,
我现在得用他的drugid再次进行查询,
rs1 = dBbean.getDBResultSet(strsql1);while(rs1.next()){
String drugid1 = rs1.getString("drugid");
strsql = "select drugid,drugtym,drugbbh,drugsf from drugzj where drugbbh='"+drugbbh+"' and drugid = '"+drugid1+"'";
rs = dBbean.getDBResultSet(strsql);}这样的速度太慢了,请问哪位有什么好的办法呢?
for (int i = 0;i<mednames.length;i++ ) {
//out.print(mednames[i]);
if (mednames[i].equals("1")) {
strsql1 = " select drugid from drugname where drugtym like '"+drugtym+"%'";
}
else if (mednames[i].equals("2")) {
strsql1 = strsql1 + " union select drugid from drugname where drughxm like '"+drugtym+"%'";
}
else if (mednames[i].equals("3")) {
strsql1 = strsql1 + " union select drugid from drugname where drugspm like '"+drugtym+"%'";
}
else if (mednames[i].equals("4")) {
strsql1 = strsql1 + " union select drugid from drugname where drugbm like '"+drugtym+"%'";
}
else if (mednames[i].equals("5")) {
strsql1 = strsql1 +" union select drugid from drugname where drugldm like '"+drugtym+"%'";
}
else if (mednames[i].equals("6")) {
strsql1 = strsql1 + " union select drugid from drugname where drugywm like '"+drugtym+"%'";
}
else if (mednames[i].equals("7")) {
strsql1 = strsql1 + " union select drugid from drugname where drugpym like '"+drugtym+"%'";
}
else {
strsql1 = strsql1 + " union select n.drugidfrom drugname n,drugcyname c where n.drugid =c.drugid and c.drugcym like '"+drugtym+"%'";
}
用以上的sql我可能要生成5000-10000或许更多的语句,
我现在得用他的drugid再次进行查询,
rs1 = dBbean.getDBResultSet(strsql1);while(rs1.next()){
String drugid1 = rs1.getString("drugid");
strsql = "select drugid,drugtym,drugbbh,drugsf from drugzj where drugbbh='"+drugbbh+"' and drugid = '"+drugid1+"'";
rs = dBbean.getDBResultSet(strsql);}这样的速度太慢了,请问哪位有什么好的办法呢?
while(rs1.next())这样写每循环一次就要做一次是否到了结果集的结尾,很费时的。
先取得记录总数
然后用for for (i=1;i<记录总数;i++)
{
....
rs1.next();
}