SELECT * FROM ip_properties WHERE prActive = 1 AND ((prLocation LIKE '{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}Pireas{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}' OR prCity = 'Pireas' OR prZip = 'Pireas' OR prStreet LIKE '{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}Pireas{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}' OR prCountry = 'Pireas') OR (prLocation LIKE '{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}Griechenland{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}' OR prCity = 'Griechenland' OR prZip = 'Griechenland' OR prStreet LIKE '{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}Griechenland{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}' OR prCountry = 'Griechenland'))
SELECT *
FROM ip_properties
LEFT JOIN ip_users ON prUserID = uID
WHERE
pr_presentation_type = 0 AND
prActive = 1 AND
(prFeaturesJSON LIKE '%"109"%' OR
(prFeaturesJSON NOT LIKE '%"109"%' AND prArea > 0))
AND ((prLocation LIKE '{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}Pireas{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}' OR prCity = 'Pireas' OR prZip = 'Pireas' OR prStreet LIKE '{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}Pireas{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}' OR prCountry = 'Pireas') OR (prLocation LIKE '{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}Griechenland{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}' OR prCity = 'Griechenland' OR prZip = 'Griechenland' OR prStreet LIKE '{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}Griechenland{1d15ebdc19b0b840c9dafc6f2add2a478e3340b5d7f4b8e88cc3cf970817c86f}' OR prCountry = 'Griechenland'))
ORDER BY
CASE
WHEN uActiveOrderID != 0 AND uActive = 1 AND uPaidUntil > CURDATE() THEN 0
ELSE 1
END,
prPaidPorAdv DESC,
prID DESC
LIMIT
0, 12