SELECT * FROM ip_properties WHERE prActive = 1 AND (((prLocation LIKE '{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}Deutschland{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}' OR prCity = 'Deutschland' OR prZip = 'Deutschland' OR prStreet LIKE '{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}Deutschland{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}' OR prCountry = 'Deutschland') OR (prLocation LIKE '{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}Germany{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}' OR prCity = 'Germany' OR prZip = 'Germany' OR prStreet LIKE '{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}Germany{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}' OR prCountry = 'Germany')) AND (prLocation LIKE '{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}Mannheim{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}' OR prCity = 'Mannheim' OR prZip = 'Mannheim' OR prStreet LIKE '{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}Mannheim{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}' OR prCountry = 'Mannheim'))
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 '{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}Deutschland{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}' OR prCity = 'Deutschland' OR prZip = 'Deutschland' OR prStreet LIKE '{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}Deutschland{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}' OR prCountry = 'Deutschland') OR (prLocation LIKE '{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}Germany{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}' OR prCity = 'Germany' OR prZip = 'Germany' OR prStreet LIKE '{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}Germany{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}' OR prCountry = 'Germany')) AND (prLocation LIKE '{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}Mannheim{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}' OR prCity = 'Mannheim' OR prZip = 'Mannheim' OR prStreet LIKE '{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}Mannheim{7d216d0babf708cfc60aaf1fc8cf962909f24d23826489356e1116bdf253ce9d}' OR prCountry = 'Mannheim'))
ORDER BY
CASE
WHEN uActiveOrderID != 0 AND uActive = 1 AND uPaidUntil > CURDATE() THEN 0
ELSE 1
END,
prPaidPorAdv DESC,
prID DESC
LIMIT
0, 12