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
  • 248,760
  • 80
  • 417
  • 510
Ahil Khan
  • 123
  • 1
  • 10

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
  • 248,760
  • 80
  • 417
  • 510