Posts
 
Reputation
Joined
Last Seen
Ranked #1K
Strength to Increase Rep
+2
Strength to Decrease Rep
-0
100% Quality Score
Upvotes Received
2
Posts with Upvotes
1
Upvoting Members
2
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
2 Commented Posts
0 Endorsements
Ranked #27.9K
Ranked #4K
~2K People Reached
Favorite Forums
Favorite Tags
Member Avatar for nishita_1

SELECT p.product_id, SUM(s.quantity) AS 'sale', SUM(p.quantity) AS 'purchase' FROM purchase p LEFT JOIN sale s ON (s.product_id=p.product_id) GROUP BY p.product_id; This should give you what you need.

Member Avatar for drmrkrch
0
1K
Member Avatar for Lloyd_4

You are defining your SQL statement in line 13 however you're not executing it. It would be mysql_query ($sql); Consult your version of php for the exact syntax as some intrinsic functions are depreciated with certain versions.

Member Avatar for drmrkrch
0
316
Member Avatar for Majestics

You will need to do an outer join select all from one table while getting the matches from another. Why are you joining on company name instead of an I'd value? Mark

Member Avatar for drmrkrch
0
164