Checking a table for time overlap?

后端 未结 4 531
走了就别回头了
走了就别回头了 2020-11-28 09:23

I have a MySQL table with the following fields:

  • name
  • starttime
  • endtime

starttime and endtime are MyS

4条回答
  •  伪装坚强ぢ
    2020-11-28 10:15

    Try this:

    declare @tempTbl table(RecID)
    
        insert into @tempTbl
        Select RecID
        from 
        (
        Select t.RecID from Table1 t,Table1 t1
        where t.StartTime between t1.StartTime AND t1.EndTime
        AND t.RecID <> t1.RecID  
    
        )
    

提交回复
热议问题