Mostly we had copied only particular values from one table to another. Similarly we had copied only particular values within a table. Now the question is rise. That is, can copy the whole column values to another column in same table? Is it possible in mysql?. Yes it is possible in mysql. We can copy the all values in one column to another within a table.
Consider a following example:
Table1 is a table name.
Now you need to add another column with named as 'Author'. The mysql query is:
Alter table Table add column Author varchar(30)
Consider a following example:
Table1 is a table name.
Now you need to add another column with named as 'Author'. The mysql query is:
Alter table Table add column Author varchar(30)
You need to copy the Game_Name column values to Author column. The mysql query as follows as:
Update tablename set column2=column1
That means, Update Table1 set Author=Game_Name.
Now You will get following as a output:
Update tablename set column2=column1
That means, Update Table1 set Author=Game_Name.
Now You will get following as a output:
Now you will get the output both the Game_name and Author column values are same.
Copy values from one column to another except some values within table:
Suppose you have to copy all values in a column except some value to another column within a table. It can be done by following mysql query:
Update Table1 set Game_Name=Author where Game_Name!='sample1'
Now you'll get all values from one column to another except some value.
Related Post:
Related Post: