Hi,
I've tried a couple of approaches to update a column in a mySQL database table from another table but am not having any luck.
I read somewhere that version 3.5.2 does not support multi-table updates and I need a code-based solution - is that correct?
If not can anybody point me in the right direction using sql?
UPDATE products SET products_ordered = (
SELECT SUM(products_quantity)
FROM orders_products
WHERE products_id = products.products_id
);
or:
Create temporary table my_temp_table
as
SELECT products_id, SUM(products_quantity) as total
FROM orders_products
GROUP BY products_id
UPDATE products, my_temp_table
SET products.products_ordered = my_temp_table.total
WHERE products.products_id = my_temp_table.products_id