Copy Data Between Tables in MySQL
Copying data between tables in MySQL is a common task for managing and maintaining databases. In this article, we will address the scenario where you need to copy specific fields from one existing table (Table 1) into a new table (Table 2) using MySQL queries.
Query to Copy Fields from Table 1 to Table 2
The following SQL query will allow you to copy data from select fields in Table 1 into Table 2:
INSERT INTO table2 (st_id, uid, changed, status, assign_status) SELECT st_id, from_uid, now(), 'Pending', 'Assigned' FROM table1
This query accomplishes the following:
Note:
The above is the detailed content of How to Copy Specific Fields Between MySQL Tables?. For more information, please follow other related articles on the PHP Chinese website!