SELECT SQL_CALC_FOUND_ROWS uqsbx_2_posts.ID
FROM uqsbx_2_posts LEFT JOIN uqsbx_2_term_relationships ON (uqsbx_2_posts.ID = uqsbx_2_term_relationships.object_id)
WHERE 1=1 AND (
uqsbx_2_term_relationships.term_taxonomy_id IN (27,33,30,29,35,31,901,34,32)
) AND uqsbx_2_posts.post_type = 'property' AND ((uqsbx_2_posts.post_status = 'publish')) AND (uqsbx_2_posts.ID IN (SELECT otr.object_id FROM uqsbx_2_terms as ot JOIN uqsbx_2_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_2_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_2_terms as ot2 JOIN uqsbx_2_term_relationships as otr2 ON otr2.term_taxonomy_id = ot2.term_id JOIN uqsbx_2_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_2_postmeta as psold WHERE psold.meta_key='show_this_property' AND psold.meta_value='1')) ) OR uqsbx_2_posts.ID IN (SELECT otr.object_id FROM uqsbx_2_terms as ot JOIN uqsbx_2_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_2_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_2_postmeta as psold WHERE psold.meta_key='show_this_property' AND psold.meta_value='1') ) )
GROUP BY uqsbx_2_posts.ID
ORDER BY
CAST(
IF( (SELECT
COUNT(ord_ot.term_id)
FROM uqsbx_2_terms as ord_ot JOIN uqsbx_2_term_relationships as ord_otr ON ord_otr.term_taxonomy_id = ord_ot.term_id
JOIN uqsbx_2_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_2_posts.ID AND ord_ott.taxonomy='property-status'
)>0, 999999999998
,
IF( (SELECT
COUNT(ord_ot.term_id)
FROM uqsbx_2_terms as ord_ot JOIN uqsbx_2_term_relationships as ord_otr ON ord_otr.term_taxonomy_id = ord_ot.term_id
JOIN uqsbx_2_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_2_posts.ID AND ord_ott.taxonomy='property-status'
)>0, 999999999999
, IF(
(SELECT COUNT(ot.term_id) FROM uqsbx_2_terms as ot JOIN uqsbx_2_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_2_term_taxonomy as ott ON ott.term_id=ot.term_id
WHERE otr.object_id=uqsbx_2_posts.ID AND ott.taxonomy='property-location' LIMIT 1)>0,
(SELECT
CASE
WHEN ot.slug='northern-ireland' THEN 1
WHEN ot.slug IS NULL THEN 4
WHEN ot.slug='' THEN 4
ELSE 2
END AS order_by_name
FROM uqsbx_2_terms as ot JOIN uqsbx_2_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_2_term_taxonomy as ott ON ott.term_id=ot.term_id
WHERE otr.object_id=uqsbx_2_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_2_postmeta as property_ordering WHERE property_ordering.meta_key='property_ordering_category_27' AND property_ordering.post_id=uqsbx_2_posts.ID LIMIT 1)>0, (SELECT property_ordering.meta_value FROM uqsbx_2_postmeta as property_ordering WHERE property_ordering.meta_key='property_ordering_category_27' AND property_ordering.post_id=uqsbx_2_posts.ID LIMIT 1), 999999) AS SIGNED) ASC
LIMIT 1, 1
SELECT SQL_CALC_FOUND_ROWS uqsbx_2_posts.ID
FROM uqsbx_2_posts LEFT JOIN uqsbx_2_term_relationships ON (uqsbx_2_posts.ID = uqsbx_2_term_relationships.object_id)
WHERE 1=1 AND (
uqsbx_2_term_relationships.term_taxonomy_id IN (27,33,30,29,35,31,901,34,32)
) AND uqsbx_2_posts.post_type = 'property' AND ((uqsbx_2_posts.post_status = 'publish')) AND (uqsbx_2_posts.ID IN (SELECT otr.object_id FROM uqsbx_2_terms as ot JOIN uqsbx_2_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_2_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_2_terms as ot2 JOIN uqsbx_2_term_relationships as otr2 ON otr2.term_taxonomy_id = ot2.term_id JOIN uqsbx_2_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_2_postmeta as psold WHERE psold.meta_key='show_this_property' AND psold.meta_value='1')) ) OR uqsbx_2_posts.ID IN (SELECT otr.object_id FROM uqsbx_2_terms as ot JOIN uqsbx_2_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_2_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_2_postmeta as psold WHERE psold.meta_key='show_this_property' AND psold.meta_value='1') ) )
GROUP BY uqsbx_2_posts.ID
ORDER BY
CAST(
IF( (SELECT
COUNT(ord_ot.term_id)
FROM uqsbx_2_terms as ord_ot JOIN uqsbx_2_term_relationships as ord_otr ON ord_otr.term_taxonomy_id = ord_ot.term_id
JOIN uqsbx_2_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_2_posts.ID AND ord_ott.taxonomy='property-status'
)>0, 999999999998
,
IF( (SELECT
COUNT(ord_ot.term_id)
FROM uqsbx_2_terms as ord_ot JOIN uqsbx_2_term_relationships as ord_otr ON ord_otr.term_taxonomy_id = ord_ot.term_id
JOIN uqsbx_2_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_2_posts.ID AND ord_ott.taxonomy='property-status'
)>0, 999999999999
, IF(
(SELECT COUNT(ot.term_id) FROM uqsbx_2_terms as ot JOIN uqsbx_2_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_2_term_taxonomy as ott ON ott.term_id=ot.term_id
WHERE otr.object_id=uqsbx_2_posts.ID AND ott.taxonomy='property-location' LIMIT 1)>0,
(SELECT
CASE
WHEN ot.slug='northern-ireland' THEN 1
WHEN ot.slug IS NULL THEN 4
WHEN ot.slug='' THEN 4
ELSE 2
END AS order_by_name
FROM uqsbx_2_terms as ot JOIN uqsbx_2_term_relationships as otr ON otr.term_taxonomy_id = ot.term_id
JOIN uqsbx_2_term_taxonomy as ott ON ott.term_id=ot.term_id
WHERE otr.object_id=uqsbx_2_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_2_postmeta as property_ordering WHERE property_ordering.meta_key='property_ordering_category_27' AND property_ordering.post_id=uqsbx_2_posts.ID LIMIT 1)>0, (SELECT property_ordering.meta_value FROM uqsbx_2_postmeta as property_ordering WHERE property_ordering.meta_key='property_ordering_category_27' AND property_ordering.post_id=uqsbx_2_posts.ID LIMIT 1), 999999) AS SIGNED) ASC
LIMIT 12, 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.