|
这是关于在网页上调用数据库的应用程序。
有一个select调用程序,有两种写法,请问哪一个调用会快一些会快一些。
一种是在页面调用两次select,一种是在数据库嵌套使用select。哪一个会快一些呢?
1.ResultSet rs_topAlert = conntop.executeQuery( "select alert from tb_ent_memb where mem_id='" + top_mem_id + "' ");
if(rs_topAlert !=null && rs_topAlert.next()){
strAlert = rs_topAlert.getString(1);
}
rs_topAlert.close();
if (strAlert.substring(0,1).equals("1")){
ResultSet rs_topCount = conntop.executeQuery( "select count(*) from tb_ent_sd_message where beizhu='0' and parentid='" + top_mem_id +"'");
if(rs_topCount !=null && rs_topCount.next()){
topCount=rs_topCount.getInt(1);
}
rs_topCount.close();
alertFlg = true;
}else{
alertFlg = false;
}
2.ResultSet rs_topCount = conntop.executeQuery( "select count(*) from tb_ent_sd_message where beizhu='0' and parentid=(select memb.mem_id from tb_ent_memb memb where substr(memb.alert,1,1)='1' and emb.mem_id='"+top_mem_id+"'));
if(rs_topCount !=null && rs_topCount.next()){
topCount=rs_topCount.getInt(1);
} |
|