In our project (the secret merlin project) at MySQL I had to fetch entries from the table which specified by a time-span with a start and a end time:
root@localhost [merlin]> select * from dc_INTEGER; +---------+------------+-------+---------------------+---------------------+ | data_id | collect_id | value | begin_time | end_time | +---------+------------+-------+---------------------+---------------------+ | 1 | 3 | 0 | 2005-10-12 13:28:04 | 2005-10-13 13:43:25 | | 2 | 1 | 94 | 2005-10-12 15:46:01 | 2005-10-13 10:22:28 | | 3 | 1 | 95 | 2005-10-13 10:22:28 | 2005-10-13 11:15:59 | | 4 | 1 | 94 | 2005-10-13 11:15:59 | 2005-10-13 13:43:31 | +---------+------------+-------+---------------------+---------------------+
The ranges never overlap for the same collect_id.
Now the problem was: How does the query look like if I want to fetch time-span …
[Read more]