SELECT DISTINCT(p.propid),r.revs, p.reviews,if(p.reviews!="",p.reviews,r.revs) as newrev,p.category_id,category.name as cat_name,p.people_sleep,p.bedrooms,p.bathrooms,p.children,p.airport,p.features,p.pets,p.smoke,p.zip,
p.wheelchair,p.prop_title,p.prop_desc,p.property_type,prop_date,display_calender,other_url_calender,is_feature,p.isilink_coid, p.isilink_prop_id, p.isilink, p.escapia, p.escapia_prop_id, p.min_rate, p.max_rate,p.min_week, p.max_week,p.min_month, p.max_month, p.review_rating, s.offer_start_date as special
FROM property p
LEFT JOIN
(
SELECT propid,count(id) revs
FROM review
WHERE status = 1
GROUP BY propid
) r
ON r.propid = p.propid
LEFT JOIN special_offer s ON ( p.propid = s.propid )
LEFT JOIN category ON (p.category_id=category.id)
LEFT JOIN effective_dates AS ed ON(ed.propId=p.propId)
WHERE p.active IN("yes","d") AND ( p.property_type="6" )
Rent this New York Vacation Rentals | NYvacationrentals.com