Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create column and copy another column into the newly created one

I'm trying to achieve a simple task, I create a new column in a table and immediately afterwards try to copy a value of some other column in the same table into the new created column but I got a

Invalid column name 'COMMENT_TMP'. error

The SQL is

Invalid column name 'COMMENT_TMP'.

ALTER TABLE TASK_COMMENT ADD COMMENT_TMP text;
UPDATE TASK_COMMENT SET TASK_COMMENT.COMMENT_TMP = COMMENT;
like image 673
simonC Avatar asked Feb 16 '11 16:02

simonC


1 Answers

Add the batch delimiter and the table name in your update statement.

ALTER TABLE TASK_COMMENT ADD COMMENT_TMP text;

GO

UPDATE TASK_COMMENT SET COMMENT_TMP = COMMENT;
like image 132
Jason Avatar answered Nov 10 '22 12:11

Jason