MySQL Forums
Forum List  »  Newbie

Update a field with another field value
Posted by: Paul Grimes
Date: September 13, 2023 12:03AM

Hello
I am trying what I thought would be a simple task, but I am struggling

I have a table as below

CREATE TABLE `labour` (
`id` mediumint(5) NOT NULL,
`Job_No` int(10) NOT NULL,
`Paying_Rate` double(7,2) NOT NULL DEFAULT '0.00',
`EngineerId` mediumint(7) NOT NULL,
`Working_Hrs` varchar(10) NOT NULL DEFAULT '0',
`InvoiceHours` varchar(10) DEFAULT NULL,
`Sheet_Returned` tinyint(1) NOT NULL DEFAULT '0',
`Invoice` double(7,2) DEFAULT '0.00',
`Send_To_Invoice` tinyint(2) NOT NULL DEFAULT '0',
`Engineer_Note` varchar(200) NOT NULL DEFAULT 'Please Select',
`VAT` decimal(5,2) NOT NULL,
`Total` double(7,2) DEFAULT NULL,
`SubTotal` double(7,2) DEFAULT NULL,
`VATAmount` double(7,2) DEFAULT NULL,
`InvoiceVAT` double(7,2) DEFAULT NULL,
`InvoiceSubtotal` double(7,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

I want to copy the values form Working_Hrs into InvoiceHours but only if Send_To_Invoice has a 1 as a value.

I have tried various combinations such as this

update `labour`
set `InvoiceHours` = `Working_Hrs`
WHERE `Send_To_Invoice` = '1'
But it is coming back with an error

As I have 79818 to go through, it would be quicker with a query than go into every record, if anybody can please help out?

Thankyou
Paul.

Options: ReplyQuote


Subject
Written By
Posted
Update a field with another field value
September 13, 2023 12:03AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.