|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Select Query
Hi All
I've managed to get somewhere with the query below with some help but it has a small problem after rigorous testing I found there is a small glitch e.g. Let’s say if I book from 10:00 to 13:00 and someone tries to book it from 08:00 to 21:00 (all day) IT WILL BOOK, meaning it will over lap. I have tried to sort it but failing miserably, anyone with any thoughts Thanks Zed Code:
SELECT b_id, COUNT(*) AS Cnt FROM booking WHERE request_date='$request_date' AND ( ($s_time >= s_time AND $s_time < e_time) OR ($e_time > s_time AND $e_time <= e_time) ) GROUP BY b_id |
|
#2
|
||||
|
||||
|
couple of questions:
1) s_time - I assume means start time. what is the datatype? I am also assuming e_time is end time and is the same datatype. 2) What exactly is this query trying to do? Find any bookings already mande for the date given? What are you trying to get out of the query? 3) what is the table structure? Use SHOW CREATE TABLE.
__________________
life is a game.... Have fun ----------------------------- http://www.phpwomen.org strength in unity PHPCommunity IRC #phpc on freenode |
|
#3
|
|||
|
|||
|
Thanks for your reply lig. I've managed to solve it with some help off course.
Code:
SELECT COUNT(*) AS Cnt FROM booking WHERE request_date = '$request_date' AND $e_time > s_time AND $s_time < e_time Quote:
|
|
#4
|
||||
|
||||
|
glad you found an answer though I am sorry it took me so long to "take a look see". Good luck.
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Select Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|