Finding free blocks of time in mysql and php?

Try this query SELECT a.id, a.start_hour, a.end_hour, TIMEDIFF(la.start_hour, a.end_hour) as `Free Time` FROM appointment as a LEFT JOIN(SELECT * FROM appointment LIMIT 1,18446744073709551615) AS la ON la.id = a.id + 1 LEFT JOIN (SELECT * FROM appointment) AS ra ON a.id = ra.id This will show these results +———————————————+ ¦ id ¦ start_hour BY ¦ … Read more