Jump to content

Include missing items in query


severndigital

Recommended Posts

So .. i have this query

 

SELECT prd.name, prd.short_desc, prd.qty_in_stock, SUM( ordprods.qty ) AS order_qtys, ord.datemade
FROM prod_list prd
INNER JOIN order_prods ordprods ON prd.id = ordprods.prodid
INNER JOIN order_list ord ON ordprods.orderid = ord.orderid
WHERE ord.datemade
BETWEEN '2008-11-01'
AND '2008-11-30'
GROUP BY prd.id
ORDER BY order_qtys ASC

 

The only problem is it does not include products from the prod_list table that were not part of an order.

 

Is there away to call this query and get the results for all products from prod_list even if they were not part of an order from order_prods

 

Thanks,

-C

 

Link to comment
https://forums.phpfreaks.com/topic/139602-include-missing-items-in-query/
Share on other sites

* UPDATE *

 

SO far i got this

 

SELECT prd.name, prd.short_desc, SUM( op.qty ) AS total_usage
FROM prod_list prd
LEFT JOIN order_prods op ON prd.id = op.prodid
WHERE prd.active = '1'
GROUP BY prd.id
LIMIT 0 , 30

 

This includes the NULL value products, but I can't seem to figure out how to implement the daterange on the third table (order_list)

 

Once I include that table, It removes all the null values.

 

Any ideas??

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.