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