You are here: Re: Complex select query « All PHP « IT news, forums, messages
Re: Complex select query

Posted by Usenet on 10/26/06 11:16

> I am trying to book rooms in a hotel. A user searches for booking from
> 1st through 10th of a month, and if I already have a booking for 5th of
> that month, then the user should get a message that booking is not
> available.
>
> What is the best way of doing this? One method I can think about it
> checking the value of all records and if any of the fields contains a
> value, the results are not displayed. However, I do not find this
> method to be very efficient. Can this be done through a single query ?

I don't s'pose this is really a php issue, it'll depend on what database
you're using. Presumably whatever that is it'll give you a way to effect
"between", because you want to find any existing bookings *between* the
start and the end date that your prospect is trying to book.

It may be doable in a single query. It might depend on your table
structure of course.

Something like :- (serving suggestion)

SELECT * FROM Bookings WHERE BETWEEN(BookingDate, NewStart, NewFinish)
AND Room=theRoom;

?
Regards
Mark

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация