SELECT `c`.`id`
FROM `chair` AS `c`
LEFT JOIN `tickets` AS `t` ON `t`.`chair_id` = `c`.`id`
AND :desiredTime < (`t`.`time_from` + INTERVAL 30 MINUTE)
AND `t`.`time_from` < (:desiredTime + INTERVAL 30 MINUTE)
WHERE `t`.`chair_id` IS NULL