How mysql inserts query data from a table into another table
MySQL database is used as an example to describe howUse the SQL command line to import all data of a table or data of a specified field to the target table.. This methodThe same applies to SQL Server databases, that is, T-SQL..
Category 1,If the fields of the two tables (the export table and the target table) are consistent and you want to insert all the data, you can use this method:
Insert into target table SELECT * from source table;
For example, to insert the articles table into the newArticles table, you can use the following SQL statement:
INSERT INTO newArticles SELECT * FROM articles ;
Category 2,If you only want to import a specified field, you can use this method:
Insert into target table (Field 1, field 2,...) SELECT field 1, field 2,... FROM source table;
Note that the fields in the preceding two tables must be consistent; otherwise, a data conversion error occurs.