I have a database table like the figure shown below,
what i want is write a query to get the current system time is in which time slot. As the result i want to retrieve the line of the relevant time slot. Is there anyone can help me with this?
I have a database table like the figure shown below,
what i want is write a query to get the current system time is in which time slot. As the result i want to retrieve the line of the relevant time slot. Is there anyone can help me with this?
create table in following format
CREATE TABLE TEST (tid int,tname varchar(10),starttime time,endtime time);
INSERT INTO TEST values (1,"a", "00:00:00","07:00:00");
INSERT INTO TEST values (2,"b", "07:00:00","19:00:00");
INSERT INTO TEST values (3,"c", "19:00:00","23:59:50");
s
elect * from TEST where starttime<time(now()) and endtime>time(now());
+------+-------+-----------+----------+
| tid | tname | starttime | endtime |
+------+-------+-----------+----------+
| 3 | c | 19:00:00 | 23:59:50 |
+------+-------+-----------+----------+
1 row in set (0.00 sec)