Say I have 2 tables A and B which contain information for start and end times respectively. The primary key is a combination of id and the timestamp. Thus, no 2 records can have the same id and timestamp
A
id | start time
1 | 2016-02-06 17:03
1 | 2016-03-09 18:09
2 | 2017-02-07 23:34
3 | 2016-02-07 19:12
3 | 2016-02-07 23:52
...
B
id | end time
1 | 2016-02-06 18:32
1 | 2016-03-09 21:11
2 | 2017-02-08 01:22
3 | 2016-02-07 21:32
3 | 2016-02-08 02:11
...
My end result should be something like
id | start time | end time
1 | 2016-02-06 17:03 | 2016-02-06 18:32
1 | 2016-03-09 18:09 | 2016-03-09 21:11
2 | 2017-02-07 23:34 | 2017-02-08 01:22
3 | 2016-02-07 19:12 | 2016-02-07 21:32
3 | 2016-02-07 23:52 | 2016-02-08 02:11
...
Obviously I can't join on just ID as the ids 1 and 3 each appear twice. I can't join on the day either as the 3rd and 5th records span across 2 different days. So is there a way to join these 2 tables? Any help would be much appreciated! Thanks!