Mysql 记录之间的平均间隔

Mysql 记录之间的平均间隔,mysql,Mysql,编辑:我有一个带有开始和结束时间字段的表。我会把公共时间间隔分组。有可能吗 假设此表: time_begin time_end 07:00 18:00 09:00 12:00 (this interval is in the first line) 17:00 18:00 (this interval is in the first line) 我想回电话: time_begin time_end 09:00 12:00 17:00 18:00

编辑:我有一个带有开始和结束时间字段的表。我会把公共时间间隔分组。有可能吗

假设此表:

time_begin time_end
07:00      18:00
09:00      12:00 (this interval is in the first line)
17:00      18:00 (this interval is in the first line)
我想回电话:

time_begin time_end
09:00      12:00
17:00      18:00
谢谢

尝试此查询

SELECT time_begin, time_end
FROM table_name
WHERE time_begin < (SELECT time_end 
                    FROM table_name
                    LIMIT 1)
AND   time_begin > (SELECT time_begin
                    FROM table_name
                    LIMIT 1)
AND   time_end < (SELECT time_end
                    FROM table_name
                    LIMIT 1)
AND   time_end > (SELECT time_begin
                    FROM table_name
                    LIMIT 1)

此查询返回第一行时间间隔之间的所有时间间隔

那很好。祝你好运。你有编程问题吗?这个网站是用来提问的,而不是用来发布你的待办事项/需求清单的。我试图更好地解释我的疑问。