0

I have record of fromtime and endtime in database table. There is fromtime= 09:00 and endtime = 10:00 so add a new fromtime= 09:05 and endtime= 10:05 then system will b show alert message that both times already exists.

I am using this sql statement

SELECT * 
FROM `tbl_timetable` 
WHERE fromtime <= '09:05' AND totime >= '10:05'

but cannot get any alert message of both times already exists.

Table image

Salman A
  • 262,204
  • 82
  • 430
  • 521
Ahil Khan
  • 227
  • 1
  • 4
  • 12

1 Answers1

2

Your query should be:

SELECT * 
FROM tbl_timetable
WHERE '10:05' > fromtime AND totime > '09:05'

Tests on DB Fiddle

Salman A
  • 262,204
  • 82
  • 430
  • 521