0

estoy haciendo un select que me llena un grid y todo bien, pero quiero que no me traiga los productos con id 9998 y 9999 todo lo demas si, pero no se como integralo en mi query, me podria ayudar, ante mano gracias

SELECT u.id, u.nombre as nombre, u.apellidos as apellido, u.roleId, p.price as precio,o.quantity as cantidad, r.name as rol, o.productName as productos, sum(o.quantity*o.price) as venta, count(distinct b.id) as cuentas 
FROM bills b join usersoperacion u on(u.id=b.userIdAbrio and u.restId=b.restId) left join roles r on(r.id=u.roleId) join orders o on(o.restId=b.restId and o.billId=b.id) join products p on (o.restId=p.restId and o.productId=p.id) left join categories c on(p.categoryId=c.id and p.restId=c.restId) left join supercategories s on(c.superCategoryId=s.id and s.restId=c.restId) 
WHERE b.statusId=2 and o.createTime between '$fechaInicio' and '$fechaFinal' and b.restId=$restId and o.statusId!=4 $s $c $p 
GROUP BY u.id, o.productName 
ORDER BY o.productName, venta desc
1
  • 2
    proba con and p.id not in (9998, 9999) en el where. el 26 feb. 2019 a las 17:36

2 respuestas 2

2

Prueba agregarle como una clausula del where el codigo:

where u.id!=9998 and u.id!=9999

Espero te funcione.

0

luego de hacer los joins puedes aplicar la clausula where para excluir los datos que no necesitas:

SELECT u.id, u.nombre as nombre, u.apellidos as apellido, u.roleId, p.price as precio,o.quantity as cantidad, r.name as rol, o.productName as productos, sum(o.quantity*o.price) as venta, count(distinct b.id) as cuentas 
FROM bills b join usersoperacion u on(u.id=b.userIdAbrio and u.restId=b.restId) left join roles r on(r.id=u.roleId) join orders o on(o.restId=b.restId and o.billId=b.id) join products p on (o.restId=p.restId and o.productId=p.id) left join categories c on(p.categoryId=c.id and p.restId=c.restId) left join supercategories s on(c.superCategoryId=s.id and s.restId=c.restId) 
WHERE p.id !=9998 and p.id!=9999 and b.statusId=2 and o.createTime between'$fechaInicio' and '$fechaFinal' and b.restId=$restId and o.statusId!=4 $s $c $p 
GROUP BY u.id, o.productName 
ORDER BY o.productName, venta desc

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.