I have tried this code and it works but only on the first instance for each customer. i.e the column should run through and add all the orders to the previous amount owing.
UPDATE customers_tbl
SET customer_amountowing = customer_amountowing +
(SELECT sorder_amount FROM standingorder_tbl
WHERE standingorder_tbl.sorder_customer = customers_tbl.customer_address1)
WHERE EXISTS
( SELECT * FROM standingorder_tbl
WHERE standingorder_tbl.sorder_customer = customers_tbl.customer_address1 );
Can anyone tell me whaere I am going wrong here. Cheers guys!!
Aucun commentaire:
Enregistrer un commentaire