SELECT SQL_CALC_FOUND_ROWS uqsbx_posts.ID
FROM uqsbx_posts LEFT JOIN uqsbx_term_relationships ON (uqsbx_posts.ID = uqsbx_term_relationships.object_id) LEFT JOIN uqsbx_term_relationships AS tt1 ON (uqsbx_posts.ID = tt1.object_id)
WHERE 1=1 AND (
uqsbx_term_relationships.term_taxonomy_id IN (862)
AND
tt1.term_taxonomy_id IN (971)
) AND uqsbx_posts.post_type = 'property' AND ((uqsbx_posts.post_status = 'publish')) AND (uqsbx_posts.ID IN (SELECT otr.object_id FROM uqsbx_terms as ot JOIN uqsbx_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_term_taxonomy as ott ON ott.term_id=ot.term_id WHERE ott.taxonomy IN('property-status') AND (ot.slug NOT IN('sold')) AND otr.object_id NOT IN(SELECT otr2.object_id FROM uqsbx_terms as ot2 JOIN uqsbx_term_relationships as otr2 ON otr2.term_taxonomy_id = ot2.term_id JOIN uqsbx_term_taxonomy as ott2 ON ott2.term_id=ot2.term_id WHERE ott2.taxonomy IN('property-status') AND (ot2.slug IN('sold')) AND otr2.object_id NOT IN(SELECT psold.post_id FROM uqsbx_postmeta as psold WHERE psold.meta_key='show_this_property' AND psold.meta_value='1')) ) OR uqsbx_posts.ID IN (SELECT otr.object_id FROM uqsbx_terms as ot JOIN uqsbx_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_term_taxonomy as ott ON ott.term_id=ot.term_id WHERE ott.taxonomy IN('property-status') AND (ot.slug IN('sold')) AND otr.object_id IN(SELECT psold.post_id FROM uqsbx_postmeta as psold WHERE psold.meta_key='show_this_property' AND psold.meta_value='1') ) )
GROUP BY uqsbx_posts.ID
ORDER BY
CAST(
IF( (SELECT
COUNT(ord_ot.term_id)
FROM uqsbx_terms as ord_ot JOIN uqsbx_term_relationships as ord_otr ON ord_otr.term_taxonomy_id = ord_ot.term_id
JOIN uqsbx_term_taxonomy as ord_ott ON ord_ott.term_id=ord_ot.term_id
WHERE ord_ot.slug IN('sale-agreed','under-offer') AND ord_otr.object_id=uqsbx_posts.ID AND ord_ott.taxonomy='property-status'
)>0, 999999999998
,
IF( (SELECT
COUNT(ord_ot.term_id)
FROM uqsbx_terms as ord_ot JOIN uqsbx_term_relationships as ord_otr ON ord_otr.term_taxonomy_id = ord_ot.term_id
JOIN uqsbx_term_taxonomy as ord_ott ON ord_ott.term_id=ord_ot.term_id
WHERE ord_ot.slug IN('sold') AND ord_otr.object_id=uqsbx_posts.ID AND ord_ott.taxonomy='property-status'
)>0, 999999999999
, IF(
(SELECT COUNT(ot.term_id) FROM uqsbx_terms as ot JOIN uqsbx_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_term_taxonomy as ott ON ott.term_id=ot.term_id
WHERE otr.object_id=uqsbx_posts.ID AND ott.taxonomy='property-location' LIMIT 1)>0,
(SELECT
CASE
WHEN ot.slug='northern-ireland' THEN 2
WHEN ot.slug IS NULL THEN 3
WHEN ot.slug='' THEN 3
ELSE 1
END AS order_by_name
FROM uqsbx_terms as ot JOIN uqsbx_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_term_taxonomy as ott ON ott.term_id=ot.term_id
WHERE otr.object_id=uqsbx_posts.ID AND ott.taxonomy='property-location'
GROUP BY otr.object_id
ORDER BY order_by_name LIMIT 1
), 5)
)
) AS SIGNED)
ASC , CAST( IF((SELECT COUNT(property_ordering.post_id) FROM uqsbx_postmeta as property_ordering WHERE property_ordering.meta_key='property_ordering_category_862' AND property_ordering.post_id=uqsbx_posts.ID LIMIT 1)>0, (SELECT property_ordering.meta_value FROM uqsbx_postmeta as property_ordering WHERE property_ordering.meta_key='property_ordering_category_862' AND property_ordering.post_id=uqsbx_posts.ID LIMIT 1), 999999) AS SIGNED) ASC
LIMIT 0, 1
SELECT SQL_CALC_FOUND_ROWS uqsbx_posts.ID
FROM uqsbx_posts LEFT JOIN uqsbx_term_relationships ON (uqsbx_posts.ID = uqsbx_term_relationships.object_id) LEFT JOIN uqsbx_term_relationships AS tt1 ON (uqsbx_posts.ID = tt1.object_id) INNER JOIN uqsbx_postmeta ON ( uqsbx_posts.ID = uqsbx_postmeta.post_id )
WHERE 1=1 AND (
uqsbx_term_relationships.term_taxonomy_id IN (862)
AND
tt1.term_taxonomy_id IN (971)
) AND (
uqsbx_postmeta.meta_key = 'price'
) AND uqsbx_posts.post_type = 'property' AND ((uqsbx_posts.post_status = 'publish')) AND (uqsbx_posts.ID IN (SELECT otr.object_id FROM uqsbx_terms as ot JOIN uqsbx_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_term_taxonomy as ott ON ott.term_id=ot.term_id WHERE ott.taxonomy IN('property-status') AND (ot.slug NOT IN('sold')) AND otr.object_id NOT IN(SELECT otr2.object_id FROM uqsbx_terms as ot2 JOIN uqsbx_term_relationships as otr2 ON otr2.term_taxonomy_id = ot2.term_id JOIN uqsbx_term_taxonomy as ott2 ON ott2.term_id=ot2.term_id WHERE ott2.taxonomy IN('property-status') AND (ot2.slug IN('sold')) AND otr2.object_id NOT IN(SELECT psold.post_id FROM uqsbx_postmeta as psold WHERE psold.meta_key='show_this_property' AND psold.meta_value='1')) ) OR uqsbx_posts.ID IN (SELECT otr.object_id FROM uqsbx_terms as ot JOIN uqsbx_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_term_taxonomy as ott ON ott.term_id=ot.term_id WHERE ott.taxonomy IN('property-status') AND (ot.slug IN('sold')) AND otr.object_id IN(SELECT psold.post_id FROM uqsbx_postmeta as psold WHERE psold.meta_key='show_this_property' AND psold.meta_value='1') ) )
GROUP BY uqsbx_posts.ID
ORDER BY CAST(uqsbx_postmeta.meta_value AS SIGNED) DESC
LIMIT 0, 12
SELECT SQL_CALC_FOUND_ROWS uqsbx_posts.ID
FROM uqsbx_posts LEFT JOIN uqsbx_term_relationships ON (uqsbx_posts.ID = uqsbx_term_relationships.object_id) LEFT JOIN uqsbx_term_relationships AS tt1 ON (uqsbx_posts.ID = tt1.object_id) INNER JOIN uqsbx_postmeta ON ( uqsbx_posts.ID = uqsbx_postmeta.post_id )
WHERE 1=1 AND (
uqsbx_term_relationships.term_taxonomy_id IN (862)
AND
tt1.term_taxonomy_id IN (971)
) AND (
uqsbx_postmeta.meta_key = 'price'
) AND uqsbx_posts.post_type = 'property' AND ((uqsbx_posts.post_status = 'publish')) AND (uqsbx_posts.ID IN (SELECT otr.object_id FROM uqsbx_terms as ot JOIN uqsbx_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_term_taxonomy as ott ON ott.term_id=ot.term_id WHERE ott.taxonomy IN('property-status') AND (ot.slug NOT IN('sold')) AND otr.object_id NOT IN(SELECT otr2.object_id FROM uqsbx_terms as ot2 JOIN uqsbx_term_relationships as otr2 ON otr2.term_taxonomy_id = ot2.term_id JOIN uqsbx_term_taxonomy as ott2 ON ott2.term_id=ot2.term_id WHERE ott2.taxonomy IN('property-status') AND (ot2.slug IN('sold')) AND otr2.object_id NOT IN(SELECT psold.post_id FROM uqsbx_postmeta as psold WHERE psold.meta_key='show_this_property' AND psold.meta_value='1')) ) OR uqsbx_posts.ID IN (SELECT otr.object_id FROM uqsbx_terms as ot JOIN uqsbx_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_term_taxonomy as ott ON ott.term_id=ot.term_id WHERE ott.taxonomy IN('property-status') AND (ot.slug IN('sold')) AND otr.object_id IN(SELECT psold.post_id FROM uqsbx_postmeta as psold WHERE psold.meta_key='show_this_property' AND psold.meta_value='1') ) )
GROUP BY uqsbx_posts.ID
ORDER BY CAST(uqsbx_postmeta.meta_value AS SIGNED) DESC
LIMIT 0, 12
Thanks for showing an interest in our research reports. For access to our archive, just add your details and we’ll get back right away with your account confirmation and the publications you’d like to read.
Thanks for showing an interest in our research reports. For access to our archive, just add your details and we’ll get back right away with your account confirmation and the publications you’d like to read.