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 9067915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:03:44+00:00 2026-06-16T17:03:44+00:00

I am doing project of hotel booking system in php and mysql I created

  • 0

I am doing project of hotel booking system in php and mysql
I created the rooms table which is below

room_no| roo_id | room_type
 D1     |  1     | Deluxe
 R1     |  2     | AC
 R2     |  3     | Non Ac
 C1     |  4     | Cottage

this table is about rooms represent total rooms in hotel.

this is customer_booking table,

customer_id | Cust_name | email | Address | room_type | room_no| cost|check_in | check_out
1 | satyawan |ss@gmail.com| xy | AC       |  R1    |5000 | 2012-12-26|2012-12-30
2 |satyawan  |   lahu@gmail.com|unr  |  Non A/C | R6 |            20002012-01-01|2012-12-07
3 |satyawan  |   lahu@gmail.com|unr  |  Non A/C | R8 |            2013-01-01  |2013-01-10
4 |satyawan  |   lahu@gmail.com|unr  |  Non A/C | R9 |            2013-01-10 |2013-01-16
5 |satyawan  |   lahu@gmail.com|unr  |  Non A/C | R6 |            2013-01-01 |2013-01-20

i have fired query on join of this both table for sort data of unbooked rooms. the query is below

SELECT *
FROM rooms 
LEFT JOIN customer_booking  
ON customer_booking.room_no = rooms.room_no
WHERE customer_booking.client_id IS NULL
OR (customer_booking.check_out >= 2013-01-01
AND customer_booking.check_in >= 2013-01-10)
OR (customer_booking.check_out <= 2013-01-01
AND customer_booking.check_out <= 2013-01-10)

but i want only data of unbooked rooms only.
if rooms is already book then it have to show that this room is already book on this date.

i cant get any idea about it.

  • 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-06-16T17:03:45+00:00Added an answer on June 16, 2026 at 5:03 pm

    Try to use this query. If the last field room_customer_id is 0 then room is free otherwise it shows customer_id who reserved this room.

    SELECT rooms.*,COALESCE(customer_booking.customer_id,0) room_customer_id
    FROM rooms 
    LEFT JOIN customer_booking  ON 
       (customer_booking.room_no = rooms.room_no)
       and 
       (
          ('2013-01-01' between customer_booking.check_in and customer_booking.check_out)
          or 
          ('2013-01-10' between customer_booking.check_in and customer_booking.check_out)
          or 
          (customer_booking.check_in between '2013-01-01' and '2013-01-10')
        )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a jQuery for hotel project. visibility hidden is not working when
I am doing project in cakephp . I want to write below query in
I am doing project in php.I used ajax code to upload the image. It
I am doing a project which will finally print a pdf file or doc
i'm doing this project Banking System This system tracks customers’ accounts in a bank.
Im doing a project of order management system and the scenario is like this
I am doing a project in which as per number getting by GET method,
I am doing project in vb.net which is already done in vb6 I am
I am student and i am doing project of Order Accepting system for five
I am doing project on heart disease prediction system. here am using Cleveland Heart

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.