SELECT SQL_CALC_FOUND_ROWS wp_hvbe690sq0_posts.ID
FROM wp_hvbe690sq0_posts LEFT JOIN wp_hvbe690sq0_postmeta ON ( wp_hvbe690sq0_posts.ID = wp_hvbe690sq0_postmeta.post_id ) LEFT JOIN wp_hvbe690sq0_postmeta AS mt1 ON ( wp_hvbe690sq0_posts.ID = mt1.post_id AND mt1.meta_key = 'ionline_property_listing_status_banner' ) LEFT JOIN wp_hvbe690sq0_postmeta AS mt2 ON ( wp_hvbe690sq0_posts.ID = mt2.post_id ) LEFT JOIN wp_hvbe690sq0_postmeta AS mt3 ON ( wp_hvbe690sq0_posts.ID = mt3.post_id ) LEFT JOIN wp_hvbe690sq0_postmeta AS mt4 ON ( wp_hvbe690sq0_posts.ID = mt4.post_id AND mt4.meta_key = 'ionline_property_listing_status_banner' ) LEFT JOIN wp_hvbe690sq0_postmeta AS mt5 ON ( wp_hvbe690sq0_posts.ID = mt5.post_id )
WHERE 1=1 AND (
(
( wp_hvbe690sq0_postmeta.meta_key = 'ionline_property_listing_status_banner' AND wp_hvbe690sq0_postmeta.meta_value != 'Sold' )
OR
mt1.post_id IS NULL
OR
( mt2.meta_key = 'ionline_property_listing_status_banner' AND mt2.meta_value = '' )
)
AND
(
( mt3.meta_key = 'ionline_property_listing_status_banner' AND mt3.meta_value != 'Withdrawn' )
OR
mt4.post_id IS NULL
)
AND
(
( mt5.meta_key = 'ionline_property_listing_status_banner' AND mt5.meta_value != 'Offmarket' )
)
) AND ((wp_hvbe690sq0_posts.post_type = 'buying_listings' AND (wp_hvbe690sq0_posts.post_status = 'publish' OR wp_hvbe690sq0_posts.post_status = 'acf-disabled')))
GROUP BY wp_hvbe690sq0_posts.ID
ORDER BY wp_hvbe690sq0_posts.post_date DESC
LIMIT 0, 12