Я хочу выбрать данные между двумя данными временем (start_time, end_time) из двух разных столбцов (start_time, end_time) на основе заданной даты и therapist_id в php mysql.
Моя база данных показана ниже
appointment_id name age email appointment_date appointment_time appointment_endtime user_id therapist_id status
4 testing 25 [email protected] 2015-11-03 01:00:00 02:00:00 2 12 SEND
3 testing 25 [email protected] 2015-11-03 01:00:00 02:00:00 2 12 SEND
2 testing 25 [email protected] 2015-11-03 01:00:00 02:00:00 2 12 SEND
1 testing 25 [email protected] 2015-11-03 05:00:00 06:00:00 2 12 SEND
Я пытаюсь написать запрос как
"SELECT therapist_id, appointment_time, appointment_endtime
FROM appointment
WHERE ((appointment_time BETWEEN '".$timee."' AND '".$end_time."' ) OR
(appointment_endtime BETWEEN '".$end_time."' AND '".$timee."') ) AND
therapist_id='".$_REQUEST['therapist_id']."' AND
appointment_date='".$_REQUEST['date']."'"
Попробуй это :
"SELECT therapist_id,appointment_time,appointment_endtime FROM appointment WHERE appointment_time>='$timee' and appointment_endtime<='$end_time'
AND therapist_id='".$_REQUEST['therapist_id']."' AND appointment_date='".$_REQUEST['date']."'"
Других решений пока нет …