Jordan Freundlich
Jordan Freundlich

Reputation: 79

How to move data from one column to another in sqlite3

I need some help formatting a table in sqlite3. I need to move all data points starting with the text "Source:" from the column they are in right now titled "Date" and put them in the column titled "Source".

I am using Python and also DB Browser. To be clear I am not trying to move all of the data points in column "Date" just the data points that start with "Source:"

Any help is greatly appreciated! Thanks!

Upvotes: 0

Views: 465

Answers (1)

sticky bit
sticky bit

Reputation: 37482

You can assign values of attributes of a row to another attribute of the row within an UPDATE.

UPDATE elbat
       SET source = date
       WHERE date LIKE 'Source:%';

(Add date = NULL if you also want to delete the contents of date in the respective rows.)

Upvotes: 1

Related Questions