A Database Error Occurred
Error Number: 1242
Subquery returns more than 1 row
select * from ( select listings.listing_id, listings.listing_name, listings.listing_uri, listings.is_featured, concat(substr(listings.description, 1, 500), '...') summary, (select min(bedrooms) from listing_rates where listing_id = listings.listing_id and bedrooms >= 0) bedrooms, (select min(bathrooms) from listing_rates where listing_id = listings.listing_id and bedrooms >= 0) bathrooms, --listings.bedrooms, --listings.bathrooms, listings.location, islands.island_name, islands.island_uri, islands.island_summary, -- listing_images.small_image, listing_images.image_key, (select min(rate_amount) from listing_rates inner join rate_types on listing_rates.rate_type_id = rate_types.rate_type_id where listing_rates.listing_id = listings.listing_id and listing_rates.end_date > now() and rate_types.type = 'high' and bedrooms >= 0 order by listing_rates.end_date limit 0, 1) high_rate, (select min(rate_amount) from listing_rates inner join rate_types on listing_rates.rate_type_id = rate_types.rate_type_id where listing_rates.listing_id = listings.listing_id and listing_rates.end_date > now() and rate_types.type = 'low' and bedrooms >= 0 order by listing_rates.end_date limit 0, 1) low_rate, ( select count(*) from listing_rates inner join rate_types on rate_types.rate_type_id = listing_rates.rate_type_id and rate_types.type = 'high' where listing_id = listings.listing_id and listing_rates.end_date > now() and -- nastiness below is just using the subquery from above to get the high rate listing_rates.rate_amount < (select rate_amount from listing_rates inner join rate_types on listing_rates.rate_type_id = rate_types.rate_type_id where listing_rates.listing_id = listings.listing_id and listing_rates.bedrooms = listings.bedrooms and listing_rates.bathrooms = listings.bathrooms and listing_rates.end_date > now() and rate_types.type = 'high' order by listing_rates.end_date limit 0, 1) ) has_lowerrates, (select attribute_value from listing_attributes inner join attributes on listing_attributes.attribute_id = attributes.attribute_id and attributes.attribute_name = 'Pool' where listing_attributes.listing_id = listings.listing_id) has_pool, (select attribute_value from listing_attributes inner join attributes on listing_attributes.attribute_id = attributes.attribute_id and attributes.attribute_name = 'Beachfront' where listing_attributes.listing_id = listings.listing_id) has_beach, (select attribute_value from listing_attributes inner join attributes on listing_attributes.attribute_id = attributes.attribute_id and attributes.attribute_name = 'Internet' where listing_attributes.listing_id = listings.listing_id) has_internet from listings inner join islands on listings.island_id = islands.island_id inner join listing_images on listings.listing_id = listing_images.listing_id and listing_images.is_primary = 1 inner join status_types on listings.status_type_id = status_types.status_type_id and status_types.status_type = 'Published' -- inner join listing_rates on listing_rates.listing_id = listings.listing_id where -- listing_rates.bedrooms >= 0 and -- listing_rates.bedrooms <= 20 and -- listings.bedrooms >= 0 and -- listings.bedrooms <= 20 1 = 1 order by -- listing_rates.rate_amount asc listings.is_featured desc ) derived_table where exists (select 1 from listing_rates where listing_id = derived_table.listing_id and listing_rates.rate_amount >= 0 and listing_rates.rate_amount <= 100000 and listing_rates.bedrooms >= 0 and listing_rates.bedrooms <= 20) and -- exists (select 1 from listing_rates where listing_id = derived_table.listing_id and listing_rates.rate_amount >= 0 and listing_rates.amount <= 100000)) and -- ((ifnull(high_rate, 0) >= 0 and -- ifnull(high_rate, 0) <= 100000) or -- (ifnull(low_rate, 0) >= 0 and -- ifnull(low_rate, 0) <= 100000)) and -- exists (select 1 from listing_rates where listing_id = derived_table.listing_id and listing_rates.bedrooms >= 0 and listing_rates.bedrooms <= 20) and 1 = 1 order by low_rate asc limit 0, 10000