Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6929561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:20:01+00:00 2026-05-27T11:20:01+00:00

I have three tables CREATE TABLE IF NOT EXISTS `tbl_hotelinfo` ( `hotel_id` int(11) NOT

  • 0

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'
        ";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:20:02+00:00Added an answer on May 27, 2026 at 11:20 am
    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables: CREATE TABLE IF NOT EXISTS `comments` ( `id` int(11) NOT
I have a table CREATE TABLE IF NOT EXISTS `dept` ( `did` int(11) NOT
I have 2 tables, items and members : CREATE TABLE IF NOT EXISTS `items`
I have in my MySQL database these two tables: CREATE TABLE IF NOT EXISTS
I have one table: CREATE TABLE IF NOT EXISTS `test` ( `firstname` varchar(100) NOT
I have following tables: CREATE TABLE IF NOT EXISTS stats ( date date NOT
I have got a problem with two tables: CREATE TABLE IF NOT EXISTS `addresses`
I have three tables. The designs were like student table create table student (studID
I've got three tables: CREATE TABLE credential_types ( id serial PRIMARY KEY, name varchar(32)
I have a table successfully created in MySQL: CREATE TABLE IF NOT EXISTS MESSAGE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.