I’m doing a query using the LIKE operator, but it doesn’t work.
When I run the query, there’s no results, but it says “Query executed successfully”.
Does anyone know why? This is what I have done:
select Pr.nomPro, Pe.fechaPedido from superVentas.dbo.Pedido Pe inner join superVentas.dbo.PedidoDetalle PD on Pe.nroPed=PD.nroPed inner join superVentas.dbo.Productos Pr on Pr.codPro=PD.codPro where month(Pe.fechaPedido)=8 and Pr.nomPro like 'A%' and Pr.nomPro like 'T%' order by Pr.nomPro go
Advertisement
Answer
One problem is a column value cannot start with ‘A’ and ‘T’ at the same time, you can use an OR operator if that is what you are looking for. Further, ‘T&’ is an incorrect way to search the wildcard.
select Pr.nomPro , Pe.fechaPedido from superVentas.dbo.Pedido Pe inner join superVentas.dbo.PedidoDetalle PD on Pe.nroPed = PD.nroPed inner join superVentas.dbo.Productos Pr on Pr.codPro = PD.codPro where month(Pe.fechaPedido) = 8 and ( Pr.nomPro like 'A%' or Pr.nomPro like 'T%' ) order by Pr.nomPro go