我有三个表 OccupancyType、RoomType 和 Hotel_MealPlan。数据是:-
占用类型数据:-
Hotel_ID Name
1 Double
1 single
680 Double
680 single
酒店_膳食计划
Hotel_ID Meal_Plan rate
1 CP 0
1 MAP 500
680 CP 400
680 EP 400
1 EP 200
房型
Hotel_ID Name Rate Season StartSeason EndSeason
680 Deluxe/Ac 2300 Diwali 2013-11-01 2013-11-15
680 Deluxe/Ac 1000 Normal NULL NULL
1 Deluxe/Ac 2700 Diwali 2013-11-01 2013-11-15
1 Deluxe/Ac 1200 Normal NULL NULL
1 Deluxe/Ac 2500 New Year 2013-12-20 2014-01-10
1 Deluxe/Ac 3800 31 Dec 2013-12-31 2013-12-31
我想要当我选择hotel_Id '1'、occupancyType Name='Double'、Meal_Plan ='MAP' 和我的房间类型名称='Deluxe/Ac' 以及 startSeason 和 EndSeason 之间的日期,或者如果开始季节为 Null 则选择 null 率。我想要这样的结果: - 下面
Name Name Rate startseason endseason Meal_Plan rate
Double Deluxe/Ac 1200 NULL NULL MAP 500
我的查询是
select o.Name,r.Name,r.Rate,r.startseason, r.endseason, m.Meal_Plan,m.rate
from OccupancyType o
inner join RoomType r on o.Hotel_ID = r.Hotel_ID
inner join Hotel_MealPlan m on m.Hotel_ID = o.Hotel_ID
where r.Hotel_ID = '1'
and r.Name = 'Deluxe/Ac'
and o.Name = 'Double'
and m.Meal_Plan = 'MAP'
and '2013-09-09' between r.startseason and r.endseason
or r.startseason is null
and r.endseason is null
我的结果是:-
Name Name Rate startseason endseason Meal_Plan rate
Double Deluxe/Ac 1200 NULL NULL CP 0
Double Deluxe/Ac 1200 NULL NULL MAP 500
Double Deluxe/Ac 1200 NULL NULL EP 200
single Deluxe/Ac 1200 NULL NULL CP 0
single Deluxe/Ac 1200 NULL NULL MAP 500
single Deluxe/Ac 1200 NULL NULL EP 200
Double Deluxe/Ac 1200 NULL NULL CP 0
Double Deluxe/Ac 1200 NULL NULL MAP 600
Double Deluxe/Ac 1200 NULL NULL CP 400
Double Deluxe/Ac 1200 NULL NULL EP 400
Double Deluxe/Ac 1200 NULL NULL MAP 600 ........
我的结果显示 48 行...我缺少什么?