Q:

SQL JOIN OPERATION

I have three tables 
CREATE TABLE IF NOT EXISTS `tbl_hotelinfo` (
  `hotel_id` int(11) NOT NULL AUTO_INCREMENT,
  `hotel_name` varchar(20) NOT NULL,
  `hotel_normal_room` int(3) NOT NULL,
  `hotel_delux_room` int(3) NOT NULL,
  `hotel_nonac_room` int(3) NOT NULL,
  `hotel_ac_room` int(3) NOT NULL,
  `hotel_owner_email` varchar(20) NOT NULL,
  `hotel_owner_index` int(11) NOT NULL,
  `hotel_state` varchar(11) NOT NULL,
  `hotel_district` varchar(11) NOT NULL,
  `hotel_phno` int(13) NOT NULL,
  `hotel_location` varchar(20) NOT NULL,
  PRIMARY KEY (`hotel_id`)
)
CREATE TABLE IF NOT EXISTS `tbl_hotelbooking` (
  `hotel_id` int(11) NOT NULL,
  `normal_room_booked` int(3) NOT NULL DEFAULT '0',
  `delux_room_booked` int(3) NOT NULL DEFAULT '0',
  `nonac_room_booked` int(3) NOT NULL DEFAULT '0',
  `ac_room_booked` int(3) NOT NULL DEFAULT '0'
)
CREATE TABLE IF NOT EXISTS `tbl_room_types` (
  `hotel_id` int(11) NOT NULL,
  `hotel_normal_room` enum('yes','no') NOT NULL DEFAULT 'no',
  `hotel_delux_room` enum('yes','no') NOT NULL DEFAULT 'no',
  `hotel_nonac_room` enum('yes','no') NOT NULL DEFAULT 'no',
  `hotel_ac_room` enum('yes','no') NOT NULL DEFAULT 'no',
  `normal_fair` int(11) NOT NULL,
  `delux_fair` int(11) NOT NULL,
  `non_ac_fair` int(11) NOT NULL,
  `ac_fair` int(11) NOT NULL
) 

now I need to join these three table to find hotel_name,hotel_location for those hotel whose  room are available 
assume that we  have the hotel_id available .first i have to find hotel_room_types available for particular hotel_id now for each room_type (which enum type yes suppose only for normal room enum type is yes) check whether tbl_hotelinfo.hotel_normal_room>tbl_hotelbooking.normal_room_booked 
i have tried
$q="SELECT total.hotel_name ,total.hotel_phno 
        FROM   tbl_hotelbooking AS book ,
        tbl_hotelinfo AS total,
        tbl_room_types AS rtype 
        WHERE
        SELECT * from tbl_room_types
        rtype.hotel_id='$hotel_id'
        ";

A:

select h.hotel_name,
       h.hotel_location,
from tbl_hotel_info h
join tbl_hotelbooking b on h.hotel_id = b.hotel_id
where h.hotel_normal_room < b.normal_room_booked
   or h.delux_room  < b.delux_room_booked
   or h.ac_room < b.ac_room_booked
   or h.nonac_room < b.nonac_room_booked;  

By the way this is a pretty awful design! Can I have normal rooms with AC or deluxe rooms without AC? The enums in room_types would appear to have no purpose.

