【问题标题】:C# Time Range CheckingC# 时间范围检查
【发布时间】:2013-09-26 05:27:28
【问题描述】:

我有一个非常棘手的问题。这个节目是关于学校的时间表。我想在我的数据库中找到一个范围内的时间。我正在使用 C# 和 MSSQL 2012。下面是我的数据库架构。

http://upic.me/show/47164036

  1. cr_id 是教室 ID。
  2. tch_id 是teacher_id。
  3. std_gro 是学生组 ID。
  4. start_time 是主题开始的时间。
  5. 结束时间是主题完成的时间。
  6. hour 是受试者花费的一个小时。
  7. subj_id 是主题 ID。
  8. day_set 是一天中的数字(例如 1=星期一)。

我想检查跨学科、教师、cr 和学生的重复项,但如何检查呢?

我试过了:

第一步:

select * from Action_Classroom where ((start_time <= 9) and (end_time > 9)) and dat_set = 2

第二步:

select * from Action_Classroom where (end_time between 9 and 9+x) and dat_set = 2 ; 

在循环中,我将小时的值作为 x 发送。

但我不知道如何检查重复时间。

如果有人给我一些例子,请告诉我,非常感谢。

【问题讨论】:

  • Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results.
  • 另外,我不知道这意味着什么:I want to check dupicate,cross over for subject , teacher, cr and student how can I check it?

标签: c# sql sql-server time timetable


【解决方案1】:
Select * 
from Action_Classroom as a join Action_Classroom as b
on a.cr_id = b.cr_id
and a.tch_id= b.tch_id
and a.day_set = b.day_set
and a.subj_id= b.subj_id
and a.start_time <= b.end_time
and b.start_time <= a.end_time

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-20
    • 1970-01-01
    • 2021-05-09
    • 2011-11-21
    • 2016-05-03
    相关资源
    最近更新 更多