都是显示A表数据+B表最低价格,B C表不做显示,做条件查询。例: 表A ID 名称 星级 推荐度 1 A 3 3 2 B 5 2 3 C 3 5表B ID 表A.ID 日期 价格 1 1 2014-11-16 100 2 1 2014-11-17 110 3 2 2014-11-16 200 4 3 2014-11-16 700表C ID 表A.ID 名称 距离 1 1 地点1 10 2 1 地点2 25 3 2 地点3 50 4 2 地点1 12 5 2 地点2 27 6 3 地点3 35如果查询条件 价格100-200之间,结果显示: 1 A 3 3 2 B 5 2 查询条件 地点3附近的数据,显示: 2 B 5 2 3 C 3 5最后还要根据 选择,按价格从低到高、距离从近到远 排序。
select hotel_list.hotel_id,name_cn,net_price,recommend from hotel_list inner join ( select hotel_id,MIN(net_price) as net_price from v_hotel_price_list where net_price>=20 and net_price<=1900 and [start_time]>='2013-1-1' and end_time<='2016-12-1' group by hotel_id ) pp on hotel_list.hotel_id=pp.hotel_id where hotel_list.hotel_id in( select hlt.hotel_id from (select distinct hotel_id from [hotel_location] where location_id>1) hlt inner join (select distinct hotel_id from [hotel_facility] where facility_id in (1,2,3,4,5,6,7,8,9,10,11,12,13,14)) hft on hlt.hotel_id=hft.hotel_id ) order by net_price,recommend desc目前写的语句,没有大量数据,不知道性能怎么样?
都是显示A表数据+B表最低价格,B C表不做显示,做条件查询。例:
表A
ID 名称 星级 推荐度
1 A 3 3
2 B 5 2
3 C 3 5表B
ID 表A.ID 日期 价格
1 1 2014-11-16 100
2 1 2014-11-17 110
3 2 2014-11-16 200
4 3 2014-11-16 700表C
ID 表A.ID 名称 距离
1 1 地点1 10
2 1 地点2 25
3 2 地点3 50
4 2 地点1 12
5 2 地点2 27
6 3 地点3 35如果查询条件 价格100-200之间,结果显示:
1 A 3 3
2 B 5 2
查询条件 地点3附近的数据,显示:
2 B 5 2
3 C 3 5最后还要根据 选择,按价格从低到高、距离从近到远 排序。
select
hotel_list.hotel_id,name_cn,net_price,recommend
from
hotel_list inner join
(
select
hotel_id,MIN(net_price) as net_price from v_hotel_price_list
where
net_price>=20 and net_price<=1900
and [start_time]>='2013-1-1'
and end_time<='2016-12-1'
group by hotel_id
) pp
on hotel_list.hotel_id=pp.hotel_id
where
hotel_list.hotel_id in(
select hlt.hotel_id from
(select distinct hotel_id from [hotel_location] where location_id>1) hlt
inner join
(select distinct hotel_id from [hotel_facility] where facility_id in (1,2,3,4,5,6,7,8,9,10,11,12,13,14)) hft
on hlt.hotel_id=hft.hotel_id
)
order by net_price,recommend desc目前写的语句,没有大量数据,不知道性能怎么样?