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 'LIMIT 5400, 18' at line 1(No Description) sql: SELECT DISTINCT(p.id), p.*, IF(p.salesrank <> 0, p.salesrank, 100000) AS salesrank FROM products p, product_tags t WHERE p.id = t.product_id AND p.parent_id = 0 AND t.tag_id = '2530' AND hidden = 0 AND enabled = 1 AND offers > 0 AND 1 = 1 ORDER BY LIMIT 5400, 18