MySQL Forums
Forum List  »  Newbie

Re: MySQL query
Posted by: Phillip Ward
Date: October 12, 2022 06:41AM


... in the end all data from column a has to added to column b and then column a should be null. How can we achieve it ?

Defined "added".

1. Value of b overwritten with value of a?
2. Value of a numerically added to the value of b?
3. Value of a concatenated to the value of b?
4. (Something else)

update table1 
  column_b = column_a                      -- (case 1) 
, column_b = column_b + column_a           -- (case 2) 
, column_b = concat( column_b, column_a )  -- (case 3) 
, column_a = NULL                          -- (All Cases)

Of course, wrap this in a Transaction so you get everything (or nothing) done in one.

Regards, Phill W.

Options: ReplyQuote

Written By
October 11, 2022 01:46PM
Re: MySQL query
October 12, 2022 06:41AM

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.