我有一张价格房间的桌子,
有三个季节(默认,低,高),我想按两个日期搜索以获得不同日期,季节的总价格..
这是我的表和查询
http://sqlfiddle.com/#!2/7ebc2/1
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)