How to Copy One Table Data Into Another Table Using MySQL Query?
Hi Dev,
In Following example you can see how to fetch data from "post" table and how to insert into "post_copy" table, so basically you have to select field of one that you want to copy and second one give name of table with proper field that you want insert. But don't forgot to give a name of field otherwise it generate error.
If you are working on php or any php framwork and you want to copy one table into other table by using sql query, so you could do it using simple SELECT and INSERT statement. just you need to think how you can use.
Example:
INSERT INTO `post_copy` (name,slug,status)
SELECT name,slug,'1' FROM `post`
I hope it could help you...
- How to Increase max_connections in MySQL?
- How to Install the PHP PDO MySQL Extension on Ubuntu 22.04?
- How to Install PHP MySQL on Linux Ubuntu?
- How to Install LEMP Stack Nginx, MySQL, PHP on Ubuntu?
- How to Change MySQL Root User Password Ubuntu?
- PHP 8 MySQL Form Validation Example
- How to Select First Row Only in PHP MySQL?
- How To Backup MySQL Database Using PHP Example