Many users can export MySQL query results to files. Generally, SELECTINTOOUTFIL is used to export query results to files, however, the method for exporting the MySQL query results to a file cannot overwrite or add the results to the created file. Example: mysqlselect11_outfiletmpt1.txt; QueryOK, 1 rowaffected (0.00sec)
Many users can export MySQL query results to files. Generally, select into outfil is used to export query results to files, however, the method for exporting the MySQL query results to a file cannot overwrite or add the results to the created file. Example: mysqlselect11_outfile '/tmp/t1.txt'; QueryOK, 1 rowaffected (0.00sec)
Many users can export MySQL query results to files. Generally, "select into outfil" is used to export query results to files, however, the method for exporting the MySQL query results to a file cannot overwrite or add the results to the created file. For example:
Mysql> select 1 into outfile '/tmp/t1.txt ';
Query OK, 1 row affected (0.00 sec)
Mysql> select 1 into outfile '/tmp/t1.txt ';
ERROR 1086 (HY000): File '/tmp/t1.txt' already exists
You can also use another method:
Mysql> pager cat>/tmp/t1.txt
PAGER set to 'cat>/tmp/t1.txt'
Mysql> select 1 ;\! Cat/tmp/t1.txt
1 row in set (0.00 sec)
+ --- +
| 1 |
+ --- +
| 1 |
+ --- +
In this way, you can easily query the differences between two SQL statements:
Mysql> pager cat>/tmp/t01.txt
PAGER set to 'cat>/tmp/t01.txt'
Mysql> select 12345 union select 67890;
2 rows in set (0.02 sec)
Mysql> pager cat>/tmp/t02.txt
PAGER set to 'cat>/tmp/t02.txt'
Mysql> select 12345 union select 67891;
2 rows in set (0.00 sec)
Mysql> \! Vimdiff-o/tmp/t0127122.16.txt
2 files to edit
+ ------- +
| 1, 12345 |
+ ------- +
| 1, 12345 |
| 1, 67890 |
+ ------- +
/Tmp/t01.txt
+ ------- +
| 1, 12345 |
+ ------- +
| 1, 12345 |
| 1, 67891 |
+ ------ +
/Tmp/t02.txt