MySQL query to copy data from one column to another column
In this post we will give you information about MySQL query to copy data from one column to another column. Hear we will give you detail about MySQL query to copy data from one column to another columnAnd how to use it also give you demo for it if it is necessary.
In this post i will tell you how to copy data from one column to another column in same table.
There is simple query to update record from one to another column in MySql.
Most of the time you just need to copy only particular record from one table to another but sometime you need to copy the whole column values to another in same table.
There will be one question in your mind, is it possible in mysql ?. Yes it is possible in mysql.
Lets assume i have a table post with column id, column1, column2 and i want to copy value of column 1 into column2.
Now use following query to copy the whole column value into another :
UPDATE 'post' SET 'column2'='column1'
Now you will get following output after running this query :
Now value of both column will be same.
Copy values from one column to another except some values within table:
If you want to copy some value of one column into another column within a table then run following queries :
UPDATE 'post' SET 'column2'='column1' where 'id'!=1
Now your output is like this :
Hope this code and post will helped you for implement MySQL query to copy data from one column to another column. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs