我想在给定日期的两个不同列(start_time,end_time)和php mysql中的therapist_id之间选择两个给定时间(start_time,end_time)之间的数据。
我的数据库显示在下面
appointment_id name age email appointment_date appointment_time appointment_endtime user_id therapist_id status
4 testing 25 notjitendra@mail.com 2015-11-03 01:00:00 02:00:00 2 12 SEND
3 testing 25 notjitendra@mail.com 2015-11-03 01:00:00 02:00:00 2 12 SEND
2 testing 25 notjitendra@mail.com 2015-11-03 01:00:00 02:00:00 2 12 SEND
1 testing 25 notjitendra@mail.com 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']."'"
答案 0 :(得分:0)
试试这个:
"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']."'"