[MySQL 5] Fetching records for common dates

Hi peps,

I have a query about a hotel’s room booking system.

Please take a look into the room table.

The following is the order table:

What query would fetch me the date(s) which has all rooms (8 in this case) booked on that date?

For this case it would be 2010-12-10 and 2010-12-20, since all 8 rooms have been booked for the date.

Please if anyone can help?

Many thanks in advance :slight_smile:

for homework, you have show us that you have made an effort yourself

hint: GROUP BY

select date_booked from orders group by date_booked ???

nice try

what did you get when you tested it?

never mind, i’ll tell you – you will get each distinct date where at least one room is booked

that’s not what you wanted, is it

:cool:

Exactly so I am still looking for the right query :smiley: