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`
Thanks for read. I hope it help you. For more you can follow us on facebook.