Mysql query to table

I need help have problem to run this query in php :

SELECT prod_code, prod_desc, SUM(pay_qty * unit_qty) as pay, SUM(free_qty * unit_qty) as free 
FROM branchsell 
WHERE bcode='1U' 
AND od_date BETWEEN DATE_SUB(DATE_SUB(CURDATE(),INTERVAL (DAY(CURDATE())-1) DAY), INTERVAL 1 MONTH) 
AND DATE_SUB(CURDATE(),INTERVAL (DAY(CURDATE())) DAY)
AND ( (prod_code BETWEEN '20000000' AND '39999999' ) 
	OR (prod_code='85000002')
	OR (prod_code BETWEEN '50000000' AND '59999999'))
GROUP BY prod_code;

What is the nature of the problem? Does it give you an error message? If so, what does it say?

Does it just not return the data you were expecting? If that’s the case, some examples of what it does, and what you want it to do, would be helpful.

Is it actually a PHP problem, or is it a problem with the query? There is no PHP code in your post.

just guessing, because you gave us no information about what’s going wrong, but try changing this –

GROUP BY prod_code

to this –

GROUP BY prod_code, prod_desc

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.