You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND i.image_id = p.product_default_image AND p.product_id = m.product_id ' at line 4

SELECT i.*, p.product_id, p.product_ip, p.product_order, p.product_code, p.product_name, p.product_images, p.product_lifespan, p.product_power, p.product_cct, p.product_lumen, p.product_date_added, MIN(m.model_price) AS min_price, m.model, m.model_price FROM products p, product_images i, product_models m WHERE p.category_id = AND i.image_id = p.product_default_image AND p.product_id = m.product_id AND p.product_active = 1 AND m.model_active = 1 -- AND m.model_price > 0 GROUP BY p.product_id ORDER BY IF(p.product_order = 0, 999999999, p.product_order), p.product_id DESC