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 'AND productos.controla_stock = 1 AND productos.stock > 0 GROUP BY marcas.id, mar' at line 1