2015-11-03 27 views
1

我想在两个给定时间(start_time,end_time)和两个不同的列(start_time,end_time)之间选择基于给定日期的数据和php mysql中的therapist_id。下面预约修复

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']."'" 
+4

“给我妥善解决”=>吗? –

+0

“给我适当的解决方案”=>有人可以帮助我走上正确的轨道吗? –

+0

1.我可以阅读这些电子邮件地址。因此,如果他们非常敏感,请考虑从您上传的图像中删除该图像。 2.看正常化。在此表中存储客户端信息显然是多余的。 3.你真的不存储'年龄',是吗? 4.出纳员将日期和时间存储为单个实体。它更高效。 – Strawberry

回答

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']."'" 
+0

我很想安排约会'';从预约中删除; --'。你认为那个日期还可以吗? – CompuChip

+0

ANSWER SELECT therapist_id,appointment_time,appointment_endtime FROM appointment WHERE((appointment_time BETWEEN'“。$ timee。”'AND'“。$ end_time。”')OR(appointment_endtime BETWEEN'“。$ timee。”'AND'“。$ )'AND ANDrapist_id ='“。$ _ REQUEST ['therapist_id']。''AND appointment_date ='”。$ _ REQUEST ['date']。'' –