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 1=1) ORDER BY t_productos.idarticulo DESC LIMIT 0, 18' at line 1SELECT DISTINCT(t_productos.idproducto), t_productos.* FROM t_productos INNER JOIN t_relaciontarifas ON t_productos.idproducto = t_relaciontarifas.idproducto WHERE borrado=0 AND stock>0 AND (codproductopadre IS NULL OR codproductopadre=0) AND visible='1' AND ( AND 1=1) ORDER BY t_productos.idarticulo DESC