会议时间冲突查询
原理:
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')";