[sql] How can I copy data from one column to another in the same table?

Is it possible to copy data from column A to column B for all records in a table in SQL?

This question is related to sql

The answer is


How about this

UPDATE table SET columnB = columnA;

This will update every row.


This will update all the rows in that columns if safe mode is not enabled.

UPDATE table SET columnB = columnA;

If safe mode is enabled then you will need to use a where clause. I use primary key as greater than 0 basically all will be updated

UPDATE table SET columnB = columnA where table.column>0;


UPDATE table_name SET
    destination_column_name=orig_column_name
WHERE condition_if_necessary