I have table with 3 columns.

  1. room_id
  2. date
  3. price
  4. availability

I needed a list of rooms with the total price within selected dates.
I could do that as follows:
SELECT SUM (price) from table WHERE date BETWEEN ( 01.08 13 AND 05.08.13 )

Now i need to have the following: in case the room was booked for 03.08.13
and in this case is column availability 0.

How can i implement this availability in this quer in order to exclude any room fron the result list if avalability on any of the dates between the chosen dates is 0 (null).

If i use only availability > 0, than i have price of all other dates where availability is greater than null, and i do not want that.

I think you should first check which rooms are available for the full duration, and then self join to get the price. Perhaps it's possible in the WHERE, not sure.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.