Re: Complex select query




"Pankaj" <panahuja@xxxxxxxxx> wrote in message
news:1161867323.670470.187190@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| between would fetch me all records in the given range. It would not
| distinguish if the value of the field is 0 or 1 (available or booked)
|
| > 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;

uhhhmmm...if BOOKINGS were a table that stored only room id's and the date
when it was NOT available, then that query would work FINE...if you changed
it to SELECT COUNT(*) and then wanted the value 0 to be returned to show a
room as available.

as it is, you've given NOTHING helpful in the way of details that helps us
help you.

btw, if you are wanting a query to only show what rooms were available for
selection, this would suffice:

SELECT r.Room ,
r.Description
FROM rooms r ,
(
SELECT Room
COUNT(*) Availability
FROM bookings
WHERE Reserved >= ' . $startDate . '
AND Reserved <= ' . $endDate . '
GROUP BY Room
) b
WHERE b.Room = r.Room
AND b.Availability = 0

not a big or complex query at all.


.



Relevant Pages

  • Re: Running a query to identify clashes
    ... All i want to do is check that there are no bookings already made for the ... Private Sub Form_BeforeUpdate ... Dim strWhere As String ... that query checks every record in the table against every other record ...
    (microsoft.public.access.queries)
  • Re: Designing a Booking System
    ... What you need is a crosstab query. ... DayPart) and then go Quriy> Crosstab to change it to a crosstab query. ... from the bookings table. ... Do Until vdat> dto ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Running a query to identify clashes
    ... that query checks every record in the table against every other record to ... Tips for Access users - http://allenbrowne.com/tips.html ... I am creating a Vehicle Bookings database and have created a query ...
    (microsoft.public.access.queries)
  • Re: Union Query with a Crosstab Query
    ... [Bookings and Pipe by Advertiser - RVP].Rep, ... The above query should show the Goals amount for just one of the records ...
    (microsoft.public.access.queries)
  • Re: Running a query to identify clashes
    ... need to compare that one against all the others, so the Cartesian query is ... Tips for Access users - http://allenbrowne.com/tips.html ... I am creating a Vehicle Bookings database and have created a query ...
    (microsoft.public.access.queries)