数据库表里有这样的数据
id issue
1 200803
2 200804
3 200805
4 200806现在我要查询200805-200807 这几个是否在数据库里存在~该怎么写才好
我是用最笨的方法 循环for(int i=200805;i<=200807;i++){
dao.search(i);
}结果就是给老大批了 效率低 请教各位帮我解决下 可以用一条sql解决最好 重要的是效率!!
id issue
1 200803
2 200804
3 200805
4 200806现在我要查询200805-200807 这几个是否在数据库里存在~该怎么写才好
我是用最笨的方法 循环for(int i=200805;i<=200807;i++){
dao.search(i);
}结果就是给老大批了 效率低 请教各位帮我解决下 可以用一条sql解决最好 重要的是效率!!
1 200803
2 200804
3 200805
4 200806 LZ的意思是说如果时间段是200805-200807那说明这里面的记录不符合要求吗?
search(startDate,endDate); 这样也能快一些
begin:
begin
**********you want to do**********
end
else
**********you want to do**********
for(int i=200805;i<=200807;i++){
q.setInteger("issur",i);
}
调用1楼写的方法
sql 可能 要看issue是什么类型的 如果是number 就像下面这写
select count(*) from yourtable where issue>to_number(startDate)and issue <to_number(endDate)如果是char型的就像下面这写
select count(*) from yourtable where issue>to_char(startDate)and issue <to_char(endDate)
应该能行吧