MySQL Forums
Forum List  »  Newbie

Re: move data to diffrent field in multiple rows
Posted by: Peter Brawley
Date: January 23, 2020 11:54AM

> update table1 set
> a = b
> , b = a

Unfortunately that will set a to b and leave b as is, you need a swap column ...

-- add swap column
alter table add column swap (same type as a & b)

-- standard swap 3-stepswap
alter table table1 set swap=a, a=b, b=swap;

-- check
select a,b from table1;

-- lose the swap col
alter table table1 drop column swap;

Options: ReplyQuote


Subject
Written By
Posted
Re: move data to diffrent field in multiple rows
January 23, 2020 11:54AM


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.