<!-- Environment: Windows 2003 SP2 + MySQL5.5.28 -
Sometimes you need to save the results that you query in one table with a SELECT statement to another table with the same structure, and you can do that with a pair of SQL statements at the command line:
Export Query Result: SELECT statement into outfile ' save path + filename ';
Import Query Result: Load data local infile ' save path + filename ' into table indicates character set UTF8;
For example:
Query the data in the table jc_archives in the database jc1992 that was published later than September 1, 2014, and save it in the Mysqltmp directory of local Disk D, save it as 1.sql, and enter it on the command line:
SELECT * from where senddate>unix_timestamp ('2014-9-1'into' D://mysqltmp/1.sql ';
Results
1.sql Open With EditPlus
Then import the 1.sql of the saved query results into the table archives of DATA_TMP in the other database and enter it on the command line:
load data local infile "D:///mysqltmp/1intotablecharacter set UTF8;
Results
This imports the query results from the first table into the second table. It is important to note that when importing, the values of the primary key or unique index of the two tables cannot be duplicated, otherwise they will skip no execution or report a warning:
MySQL command line export, import Select query results