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