首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

集会时间冲突查询

2012-09-11 
会议时间冲突查询原理:Select * from 会议表 As t1 ,会议表 t2 where (( t2.起始t1.起始 and t2.结束t1

会议时间冲突查询
原理:
Select * from 会议表 As t1 ,会议表 t2
where (
( t2.起始<=t1.起始 and t2.结束>t1.起始 ) or
( t2.起始<t1.结束 and t2.结束>=t1.结束 ) or
( t2.起始>t1.起始 and t2.结束<t1.结束 )
) and t1.id<>t2.id

真实使用:
String  hyctSql = "select distinct(a.task_id) from t_dat_task a, t_dat_task b where";
hyctSql = hyctSql + " ((b.begin_time<=a.begin_time and b.end_time>a.begin_time) or (b.begin_time<a.end_time";
hyctSql = hyctSql + " and b.end_time>=a.end_time) or (b.begin_time>a.begin_time and b.end_time<a.end_time))";
hyctSql = hyctSql + " and a.task_id <> b.task_id and a.extactor_cn like '%"+leadList.get(l)+"%'";
hyctSql = hyctSql + " and b.extactor_cn like '%"+leadList.get(l)+"%'";
hyctSql = hyctSql + " and b.begin_time>=to_date('"+datetime+" 00:00:00','yyyy-mm-dd hh24:mi:ss')";
hyctSql = hyctSql + " and b.begin_time<=to_date('"+datetime+" 23:59:59','yyyy-mm-dd hh24:mi:ss')";

热点排行