skij
asked on
MySQL: Update column with sum of other columns
What is wrong with this MySQL query?
Error: Invalid use of group function
UPDATE `sales` SET `sale_received` = sum(`sale_products_subtotal` + `sale_shipping_charged` + sale_tax) WHERE `sale_payment_status` = 'Paid in Full'
It returns an error:Error: Invalid use of group function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both. zephyr_hex, your idea returned an error:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE sale_payment_status = 'Paid in Full' GROUP BY sale_id) AS grp ON' at line 5
themrrobert, your idea worked.
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE sale_payment_status = 'Paid in Full' GROUP BY sale_id) AS grp ON' at line 5
themrrobert, your idea worked.
Open in new window