Jump to content

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??

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.