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