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 p.marca = m.id and (p.marca =  or p.Categoria = )  and p.Status not in ('...' at line 2 select p.ID, m.Nombre as Marca, p.Status, p.Foto, p.URL, p.Foto2, p.Relacionado, p.NombreWeb as Nombre, p.PrecioRegular  as Precio, p.PrecioFinal as PrecioFinal
from producto_web p, marca m where p.ProductoID <>  and p.marca = m.id and (p.marca =  or p.Categoria = )  and p.Status not in ('SOLO') order by (case when p.Marca =  then 1 else 2 end) asc,  p.ID limit 0,4