我想基于给定日期和PHP mysql中的Therapist_id从两个不同的列(start_time,end_time)中选择两个给定时间(start_time,end_time)之间的数据。
我的数据库如下所示
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']."'"
关于php - 预约预约,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33497238/