Truy vấn này kiểm tra xem bạn có @x/5 không các vị trí miễn phí trong @x tiếp theo phút. Và nếu vậy, hơn chúng bao gồm toàn bộ @x khoảng cách phút, có nghĩa là chúng liên tiếp.
set @x=15;
select distinct t1.date
from
`agenda_specialists` as t1 join
`agenda_specialists` as t2 on
t2.date=t1.date and
t2.begin>=t1.begin and
t2.begin<addtime(t1.begin,sec_to_time(@x*60))
group by t1.id
having count(*)example@sqldat.com/5
https://sqlfiddle.com/#!2/54d9f6/50