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 '100' at line 1 Sql:SELECT id,producto,barCode,costoPonderado FROM co_producto_detalle WHERE (SELECT proveedor FROM co_productos_bas WHERE id = co_producto_detalle.producto) = '' AND existencias < 4 ORDER BY barCode limit ,100