24

What is the easiest way to copy the all the values from a column in a table to another column in the same table?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Hoopy Frood
  • 343
  • 1
  • 3
  • 5

2 Answers2

50

With a single statement (if the columns have the same datatype)

UPDATE <tablename>
SET <destination column name> = <source column name>
Panagiotis Korros
  • 10,840
  • 12
  • 41
  • 43
15

This script will update ALL values in the field1 with the values from the field2 in the corresponding row

UPDATE table SET field1 = field2
Ilya Kochetov
  • 17,988
  • 6
  • 44
  • 60