severndigital Posted November 17, 2008 Share Posted November 17, 2008 i need to get the SUM of a field from one table based off a range in another table here's what i think it should should like in the end, but of course it isn't working SELECT SUM(prd.qty) FROM order_products prd WHERE order_list.datemade BETWEEN UNIX_TIMESTAMP('2008-10-01') AND UNIX_TIMESTAMP('2008-10-31') i should mention that the tables look like this order_list table id datemade etc.... order_prods table id orderid prodid qty etc... i just can't get this query to show up. Any suggestions?? Thanks -C Quote Link to comment https://forums.phpfreaks.com/topic/133102-wierd-imo-query-help-me-build-please/ Share on other sites More sharing options...
fenway Posted November 17, 2008 Share Posted November 17, 2008 "Show up"? I assume the query doesn't fail? How are you requesting this column? Quote Link to comment https://forums.phpfreaks.com/topic/133102-wierd-imo-query-help-me-build-please/#findComment-692179 Share on other sites More sharing options...
rhodesa Posted November 17, 2008 Share Posted November 17, 2008 you need a join there...try this: SELECT SUM(prd.qty) FROM order_products prd LEFT JOIN order_list lst ON lst.id = prd.orderid WHERE lst.datemade BETWEEN UNIX_TIMESTAMP('2008-10-01') AND UNIX_TIMESTAMP('2008-10-31') Quote Link to comment https://forums.phpfreaks.com/topic/133102-wierd-imo-query-help-me-build-please/#findComment-692180 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.