逻辑问题帮忙...A,B,C,D四个答案.....
每个题目对应A,B,C,D四个答案.....
我想查某个答案在答案表中的数据有多少条.简单的说下就是查有多少个count(id),同时还想查下 每个该id下 的A,B,C,D分别有多少个?
难不成我真的按照我上面写的方法分别查询where youAnswer="+"A"; youAnswer="+"B";youAnswer="+"C";youAnswer="+"D"; 。。。那样速度会不会忒慢了点啊 。。。每个查询用p处理语句。。返回结果集。。怎样是部是很麻烦啊且性能不好 。。有每好点的方法咯 。。请赐教。
public ArrayList countMany(){
String mysql;
String mysql2="select count(youAnswer) from empAnswer where youAnswer="+"A"; //selectA
String mysql3="select count(youAnswer) from empAnswer where youAnswer="+"B"; //selectB;
String mysql4="select count(youAnswer) from empAnswer where youAnswer="+"C"; //selectC;
String mysql5="select count(youAnswer) from empAnswer where youAnswer="+"D"; //slecctD;
getCon=tion.getCon();
myList =new ArrayList();
for(int i=0;i<myArray.size();i++){ //循环所有的答案编号,里面全是问题表里面的编号ID
int many =Integer.parseInt(myArray.get(i).toString());
mysql="select count(examtid) from empAnswer where examtid="+many; //统计某题出现次数,,问题表中的examtid和many相等时。empAnswer答案表
try{
PreparedStatement pst=getCon.prepareStatement(mysql);
st=pst.executeQuery();
while(st.next()){
certain = new CertainQ();
certain.setQuestionNumber(many); //保存这个编号
certain.setQuestionAppear(st.getInt(6)); //出现多少次.....这个编号为many的id总共条数....
myList.add(certain);
PreparedStatement pst1=getCon.prepareStatement(mysql2);
while(st2.next()){
you =new YouQuestion();
you.setSelectA(st2.getInt(4));
}
}
}catch(Exception ex){
ex.printStackTrace();
}
} return myList;
}