robertth wrote:
> My question is very simple right now I have 4 fields - monthpay - annualpay - depositpay and
> totalorder.
>
> What I'm trying to do is total the monthpayand annualpay (one of which will be 0 ) and then
> subtract the depositpay and have the results go into the totalpay field.
USE test;
DROP TABLE IF EXISTS payroll;
CREATE TABLE payroll (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
monthpay DECIMAL(10,2) NOT NULL DEFAULT 0.00,
annualpay DECIMAL(10,2) NOT NULL DEFAULT 0.00,
depositpay DECIMAL(10,2) NOT NULL DEFAULT 0.00,
totalpay DECIMAL(10,2) NOT NULL DEFAULT 0.00
);
INSERT INTO payroll (monthpay, annualpay, depositpay) VALUES
(100.00, 0.00, 40.00),
(0.00, 1500.00, 180.00);
UPDATE payroll
SET totalpay = monthpay + annualpay - depositpay;
--
felix
Please use
BBCode to format your messages in this forum.