如果没有时间冲突如何插入时间表(冲突) [英] How to insert into time table if no time conflict (Clash)

查看:75
本文介绍了如果没有时间冲突如何插入时间表(冲突)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查时间表中的时间冲突,如果没有时间冲突,那么插入一个新的约会?

如果没有时间冲突,我想预订房间没有空房间。 />
首先如何编写acode来检查这两条记录中的时间冲突,至少返回0,如果没有时间冲突,则插入一条新记录。



i尝试以下但是它给了我以下这些记录,我也试过计数(*),结果是2这是不正确的,它应该是0。



i想要检查时间冲突,具体取决于(日期名称)和两者(start_time),(End_time)



How to check time conflict in time table and if no time conflict then insert a new appointment ?
I want to book a room if there is no time conflict with exist none empty room.
So first how to write acode for checking time conflict in these two records at least and it returns 0 , then insert a new record if there is not time conflict.

i tried the following but it gives me these records below, also i tried count(*) and the result was 2 which is not correct, it supposed to be 0 .

i want to check time conflict depending on (day name) and both (start_time), (End_time)

SELECT t2.* FROM
Room_Information  t1
 INNER JOIN
 Room_Information  t2
 on
     (t1.Start_Time   < t2.End_Time
       and
    t1.End_Time  > t2.Start_Time) and (t1.Day_Name=t2.Day_Name) and t1.Schedule_ID = t2.Schedule_ID and t1.Term_ID=118 and t1.room_id=140 ;





这是我的桌子



Term_Desc | Ac_Course_Code | DAY_NAME | Time_Desc | END_TIME | Room_No | Section_Name | Room_ID | Term_ID | Schedule_ID

Summer I 2001 | COS 25 |星期天| 10.30 | 12.00 | 7001-M3017 | D1 | 140 | 150 | 18915

Summer I 2001 | COS 25 |星期天| 14.00 | 15.00 | 7001-M3017 | D2 | 140 | 150 | 18928



and this is my table

Term_Desc| Ac_Course_Code| Day_Name| Time_Desc| End_Time| Room_No| Section_Name | Room_ID | Term_ID | Schedule_ID
Summer I 2001 | COS 25 | Sunday | 10.30 | 12.00 | 7001-M3017 | D1 | 140 | 150 | 18915
Summer I 2001 | COS 25 | Sunday | 14.00 | 15.00 | 7001-M3017 | D2 | 140 | 150 | 18928

推荐答案

更改它以返回COUNT而不是项目,只有在值为零时才执行插入。
Change it to return the COUNT instead of the items, and only do the insert if the value is zero.


我尝试了你的解决方案但没有工作

i用我的表更新我的问题和结果请检查
i tried your solution but not working
i update my question with my table and result please check


这篇关于如果没有时间冲突如何插入时间表(冲突)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆