Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.63 KB | None | 0 0
  1. SELECT orderproducts.*,
  2.        SUM(quantity) AS `total`,
  3.        products.name AS ownname
  4. FROM   `orderproducts`
  5.        LEFT JOIN `products`
  6.          ON orderproducts.product_id = products.prodid
  7.        LEFT JOIN `orders`
  8.          ON orderproducts.order_id = orders.order_id
  9. WHERE  `product_id` != 'Z2001'
  10.        AND ( `product_id` LIKE 'E%'
  11.               OR `product_id` LIKE 'M%'
  12.               OR `product_id` LIKE 'X%'
  13.               OR `product_id` LIKE 'U%'
  14.               OR `product_id` LIKE 'CM%' )
  15.        AND orderproducts.order_id > '76'
  16.        AND orders.valid = '1'
  17. GROUP  BY `product_id`
  18. ORDER  BY `total` DESC
  19. LIMIT  10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement