How to copy one table data into another table in Mysql Query?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Today now in this blog i will show you how to copy one table data into another table by using mysql query. If we are working on php or any other php framwork and we need to copy one table date into other table by using sql query, so here i will show you how we could do it by using a simple SELECT and INSERT statement.It is just we need to think how we can use.

Now in following example we can see how to fetch data from a “post” table and how to insert into “post_copy” table, so it is basically we have to select field of one that we want to copy one and second one give name of table also with proper field that we want insert. But we don’t forgot that give a name of field otherwise it will generate error.

INSERT INTO `post_copy` (name,slug,status)
SELECT name,slug,'1' FROM `post`

Read Also : How to Open Link in New Window by using Javascript ?

Thanks for read. I hope it help you. For more you can follow us on facebook.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →