写sql 比较时间大小

来源:互联网 发布:循环倒计时软件 编辑:程序博客网 时间:2024/04/28 13:12
 public Page queryUpRoom(RoomModel roomModel, int page, int rows,
   String startTime, String endTime) throws Exception {
  // ROOM_NAME,t.ROOM_ID,t.ROOM_ADDRESS,t.CONTACT_TEL,t.MAX_NUM
  String sql = "select t.* from t_room t where t.status=1 and t.room_id not in("
    +
    "select DISTINCT MEETING_ROOM_ID from t_room_apply where APPLY_STATUS='3' AND ((START_TIME>='"
    + startTime
    + "' and END_TIME<='"
    + endTime
    + "') OR (START_TIME>='"
    + startTime
    + "' and START_TIME<='"
    + endTime
    + "')OR ( END_TIME<='"
    + endTime
    + "' and END_TIME>='" + startTime + "'))"
    + ")";


//----------------------
综上 的sql 如下; 
select t.* from t_room t where t.status=1 and t.room_id not in(select DISTINCT MEETING_ROOM_ID from t_room_apply where APPLY_STATUS='3' AND ((START_TIME>='2014-08-04 10:26:15' and END_TIME<='2014-08-04 10:50:22') OR (START_TIME>='2014-08-04 10:26:15' and START_TIME<='2014-08-04 10:50:22')OR ( END_TIME<='2014-08-04 10:50:22' and END_TIME>='2014-08-04 10:26:15')))
0 0