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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:48:28+00:00 2026-06-16T18:48:28+00:00

I have a hotel booking system, when the user chooses the start date and

  • 0

I have a hotel booking system, when the user chooses the start date and end date for staying in the hotel, I want to give the total price:

For example: when the user chooses Start date: 2013-08-01, to : 2013-08-11 (two season default, and high season) also the price of days is different.


This is my table:

enter image description here

How can write a SQL command (MySQL) or do I need to use PHP code?

  • 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-16T18:48:29+00:00Added an answer on June 16, 2026 at 6:48 pm

    Your data structure is not set up to do this very efficiently. However, it is still possible.

    I would start by splitting out each date of the stay separately. Join this to the rates table. Then use a big case statement based on day of the week to get the rate. If there is no match in the rate table, then use the default rate:

    select sum(case when dayname(thedate) = 'Monday' then coalesce(r.MonPrice, def.MonPrice)
                    when dayname(thedate) = 'Tuesday' then coalesce(r.TuePrice, def.TuePrice)
                    . . .
                    when dayname(thedate) = 'Sunday' then coalesce(r.SunPrice, def.SunPrice) as TotalPrice
    from (select strtodate('2013-08-01', '%Y-%m-%d') as thedate union all
          select strtodate('2013-08-02', '%Y-%m-%d') union all
          . . . 
          select strtodate('2013-08-11', '%Y-%m-%d')
         ) dates left outer join
         Rates r
         on dates.thedate between r.date_to and r.date_from cross join
         Rates def
         on def.season_price = 'default'
    

    In this example, I’ve the dates are each put into a subquery. There are other ways to do this, but since you are constructing the query in php, this might be the easiest solution.

    The “…” mean to add similar SQL code, since “…” is not recognized as part of SQL.

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

Sidebar

Related Questions

Imagine that you want to design a tennis booking system. You have 5 tennis
I'm working on a hotel booking timeline feature for hotel management system. I have
Using CakePHP 1.3 we have a booking system for hotel rooms. A check-availability form
I have this schema: Hotel (**hotelNo**, hotelName, city) Room (**roomNo, hotelNo**, type, price) Booking
I have php mysql calneder for my hotel room booking system. but it shows
I have a hotel with two domains. Now the customer want a redirect: domain1.dk/folder/
I am building an online hotel booking system.... Using php and mysql.... Users can
I am doing project of hotel booking system in php and mysql I created
I have a URI template in the form of /hotels/{hotel}/bookings/{booking}, and can access the
I have a DB with 4 tables: booking, hotel, guest and room. I'm trying

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.