2015-11-03 30 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']。'' –