sqlite

SQLITE - switch data in columns


I've got a table with the following structure:

CREATE TABLE "mytable" ("column01" INTEGER NOT NULL , "column02" INTEGER NOT NULL )

And I want to switch the values between columns - I want column02 to become column01 and column01 to become column02.

i.e.:

column01 / column02
apple / 01
day / 05
light / 28

And I want it to become:

column01 / column02
01 / apple
05 / day
28 / light

Is there a way to achieve this, using only SQL query?

Thanks.


Solution

  • I just tested the below query and it works:

    update mytable set column01 = column02, column02 = column01