私は価格部屋のテーブルを持っています、
3 つの季節 (デフォルト、低、高) があります。2 つの日付で検索して、異なる日、季節の合計価格を取得したいと考えています。
これは私のテーブルとクエリです
http://sqlfiddle.com/#!2/7ebc2/1
5日間の合計金額を計算する方法(mysql)ホテル予約システム
select sum(coalesce(prices.room_price , def.room_price) ) as TotalPrice
from (select strtotime('2013-05-07' , '%Y-%m-%d') as thedate union all
select strtotime('2013-05-08' , '%Y-%m-%d') as thedate
) dates left outer join
SH_rooms_price prices
on dates.thedate between prices.start_season and prices.end_season and
dayname(dates.thedate) = prices.day_of_week join SH_rooms_price def
on def.season_price = 'default' and
def.id_hotel = 5544 and
def.day_of_week = dayname(dates.thedate)