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