Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create copy of one column in same table mysql [closed]

Tags:

sql

mysql

I have a table with one columns of integer data type. I want to add another columns with string data type.

Finally I want to copy the values in first column to the second columns. That means I want to copy the integer data from column one and copy that to second column in string format.

like image 361
rushikesh.meharwade Avatar asked Dec 20 '22 03:12

rushikesh.meharwade


1 Answers

Casting the column to a CHAR will do what you want:

UPDATE `table` SET column2 = CAST(column1 AS CHAR)
like image 116
apartridge Avatar answered Mar 09 '23 21:03

apartridge