id i o
----------
1 11 22
2 31 42
3 35 45
31..42 + 35..45
45
, а в 45 + (42 - 35) = 52
SELECT `i1`.`i`, `i1`.`o`, `i2`.`i`, `i2`.`o`,
(IF(`i1`.`o` > `i2`.`o`, `i2`.`o`, `i1`.`o`)
- IF(`i1`.`i` > `i2`.`i`, `i1`.`i`, `i2`.`i`)) AS `crosstime`
FROM `table` AS `i1`
JOIN `table` AS `i2` ON `i2`.`id` > `i1`.`id`
AND `i1`.`i` < `i2`.`o` AND `i2`.`i` < `i1`.`o`