如题 我要查询一大堆东西
String dept="select dept_name from dept; _";
String cn="select count(*) from emp where emp_dept=? and to_char(emp_joindate,'yyyy-mm')<'"+years+"-"+month+"'; _";
String ce="SELECT COUNT(*) FROM emp WHERE to_char(emp_joindate,'yyyy-mm') ='"+years+"-"+month+"' and emp_dept=?; _";
String cd="select count(*) from el where to_char(el_date,'yyyy-mm')='"+years+"-"+month+"' and emp_dept=?; _";
String cf="select count(*) from dr where to_char(dr_date,'yyyy-mm')='"+years+"-"+month+"' and dr_dept_a=?; _";//dr_depr_a是名称
String co="select count(*) from dr where to_char(dr_date,'yyyy-mm')='"+years+"-"+month+"' and dr_dept_f=?; _";//dr_depr_a是名称
String cgs="select count(*) from emp where to_char(emp_jiondate,'yyyy-mm')='"+years+"-"+month+"' and emp_dept=? and emp_education='研究生'; _";
String cuc="select count(*) from emp where to_char(emp_jiondate,'yyyy-mm')='"+years+"-"+month+"' and emp_dept=? and emp_education='本科生'; _";
String cjc="select count(*) from emp where to_char(emp_jiondate,'yyyy-mm')='"+years+"-"+month+"' and emp_dept=? and emp_education='大专生'; _";
String cshs="select count(*) from emp where to_char(emp_jiondate,'yyyy-mm')='"+years+"-"+month+"' and emp_dept=? and emp_education='高中级以下'";
String sql=dept+cn+ce+cd+cf+co+cgs+cuc+cjc+cshs;应该怎么连接 才能让这个包含所有sql语句的sql字符串顺利执行
String dept="select dept_name from dept; _";
String cn="select count(*) from emp where emp_dept=? and to_char(emp_joindate,'yyyy-mm')<'"+years+"-"+month+"'; _";
String ce="SELECT COUNT(*) FROM emp WHERE to_char(emp_joindate,'yyyy-mm') ='"+years+"-"+month+"' and emp_dept=?; _";
String cd="select count(*) from el where to_char(el_date,'yyyy-mm')='"+years+"-"+month+"' and emp_dept=?; _";
String cf="select count(*) from dr where to_char(dr_date,'yyyy-mm')='"+years+"-"+month+"' and dr_dept_a=?; _";//dr_depr_a是名称
String co="select count(*) from dr where to_char(dr_date,'yyyy-mm')='"+years+"-"+month+"' and dr_dept_f=?; _";//dr_depr_a是名称
String cgs="select count(*) from emp where to_char(emp_jiondate,'yyyy-mm')='"+years+"-"+month+"' and emp_dept=? and emp_education='研究生'; _";
String cuc="select count(*) from emp where to_char(emp_jiondate,'yyyy-mm')='"+years+"-"+month+"' and emp_dept=? and emp_education='本科生'; _";
String cjc="select count(*) from emp where to_char(emp_jiondate,'yyyy-mm')='"+years+"-"+month+"' and emp_dept=? and emp_education='大专生'; _";
String cshs="select count(*) from emp where to_char(emp_jiondate,'yyyy-mm')='"+years+"-"+month+"' and emp_dept=? and emp_education='高中级以下'";
String sql=dept+cn+ce+cd+cf+co+cgs+cuc+cjc+cshs;应该怎么连接 才能让这个包含所有sql语句的sql字符串顺利执行
解决方案 »
- 怎么用Java编写用户登陆界面
- ComboBox显示数据
- 用户名,手机等不能重复是放在一个方法里面处理还是分别处理?
- myeclipse中导入ssh项目部署运行时候不能在数据库中自动生成表
- j2ee开发问题
- Telnet server,socket 编程,character based screen 就像早期的BBS一样, 用JAVA能实现吗
- 概念性问题,struts,hibernate
- 求救,关于schema的问题
- ejb中cmp方式怎么样使用数据库连接池呀
- ssh 报java.lang.NullPointerException 错误
- 想用hql查询出一个date字段的日期为今天日期的记录
- 求教maven打包问题
更新系的倒是有executeBatch()的,
查询系执行逐条执行,然后对每个返回集再add之类的。
感觉也没必要。
你那些sql字段基本一样的。多数都是参数传的不一样,完全可以通过一条sql分组得到你要的数据,这样写来,你的sql可以减少为5句各自执行 也没那么多了啊。
如果部分表即使没有外键关联, 但是数据是关联关系数据的话,改成连接查询,估计能缩小到一两条sql!!!