我有如下的mysql查询
SELECT
p.prop_name,
p.prop_id,
p.star,
c. NAME,
pr.prov_name,
c.countryid,
c. NAME,
pr.provinceid,
r.room_typeid,
r.roomtype_name,
rr.is_promo,
r.price,
rr.final_price FROM
v_property p
INNER JOIN set_country c ON(p.countryid = c.countryid)
INNER JOIN set_province pr ON(p.provinceid = pr.provinceid)
INNER JOIN room_type r ON(p.prop_id = r.prop_id)
INNER JOIN room_rate_promo rr ON(r.room_typeid = rr.room_typeid)
WHERE
rr.date = '2015-11-09'
AND p.is_active = 1
AND rr.rating_status = 'ON'
AND p. STATUS = 1
AND p.provinceid = '5'
ORDER BY
rr.final_price ASC
结果显示如下
我想让
prop_name
仅显示每个prop_name
的一行,并按最小final_price
列获取,并按is_promo
排序 最佳答案
你快到了。只需在“选择”之后添加“ TOP 1”即可。因此它将是:
SELECT TOP 1
/* etc... */
关于php - 从MySQL与订单字段选择查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34011750/