This is my SQLite Database Table :
+----+-----------+----------+
| ID | StartTime | EndTime |
+----+-----------+----------+
| 1 | 07:00:01 | 23:00:00 |
| 2 | 23:00:01 | 07:00:00 |
+----+-----------+----------+
Now I am having problem creating sql query to select them.
Time1=’14:00:00′
I used
SELECT * FROM 'table'
WHERE StartTime <= '14:00:00'
AND EndTime >= '14:00:00';
Result for selecting Time1 returned is correct, I got what I want.
But
Time2=’07:00:00′Time3=’06:00:00′
For Time2 and Time3, I can’t seems to determine what should be the SELECT statement conditions?
QUESTION
What should be the algorithm and SQLite statements to handle such situation, i.e. when it’s Time1, only ID 1 is returned, when Time2 and Time3, only ID 2 is returned?
I am using Java to execute SQLite statements, therefore I am not sure if all the functions are supported.
Here is an example query (SQLFiddle):