SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-30,30' at line 28. Failing Query: "SELECT * FROM (SELECT
opm.id_os_product_model,
opm.price,
IF(osp.discount_percent IS NULL OR os.status IS NULL, opm.offer_price, (opm.price * (1 - (osp.discount_percent/100)))) as offer_price,
IF(osp.discount_percent IS NULL OR os.status IS NULL, opm.discount_percent, osp.discount_percent) as discount_percent,
CASE opm.product_type
WHEN "NORMAL" THEN IF(osp.discount_percent IS NOT NULL AND osp.discount_percent > 0 AND os.status IS NOT NULL, "OFFER", "NORMAL")
WHEN "NEW" THEN IF(osp.discount_percent IS NOT NULL AND osp.discount_percent > 0 AND os.status IS NOT NULL, "OFFER", "NEW")
WHEN "OFFER" THEN opm.product_type
WHEN "OUTLET" THEN opm.product_type
END as product_type,
opm.product_type as original_type,
opm.according_to_size,
opm.new_discount,
op.id_os_product, op.gender,
opl.name as product_name, opl.long_description,
om.name as manufacturer_name,
#oc.*,
opmr.rate
FROM os_product_model opm
LEFT JOIN os_product op ON (op.id_os_product = opm.fk_product)
LEFT JOIN os_sale_product osp ON osp.fk_product = opm.fk_product AND osp.fk_product_model = opm.id_os_product_model
LEFT JOIN os_sale os ON os.status = "ENABLE" AND os.idos_sale = osp.fk_idos_sale AND ((os.start_date <= "2016-12-09 14:28:52" AND os.finish_date > "2016-12-09 14:28:52" ) OR (os.start_date IS NULL AND os.finish_date IS NULL ))
LEFT JOIN os_product_language opl ON ((opl.fk_product = op.id_os_product AND opl.fk_language = "ES"))
LEFT JOIN os_manufacturer om ON (om.id_manufacturer = op.fk_manufacturer)
LEFT JOIN os_category oc ON (oc.sage_family = op.fk_sage_family)
LEFT JOIN os_product_model_rating opmr ON (opmr.fk_product = opm.fk_product AND opmr.fk_product_model = opm.id_os_product_model)
WHERE (opm.visible = 1 AND op.visible = 1 AND op.pending = 0 AND om.visible = 1 AND oc.visible = 1) AND (opl.name LIKE '%012%' OR op.id_os_product LIKE '%012%') ORDER BY offer_price ASC ) as resultado GROUP BY id_os_product,id_os_product_model ORDER BY offer_price ASC LIMIT -30,30"